使用 jquery.form 发布后的响应未添加到目标 div
我正在使用 jQuery 表单来发布数据。我正在从服务器发送一些响应,我希望这些响应出现在使用目标选项指定的 div 中。我可以在 firebug 中看到响应实际上返回到浏览器,但信息没有出现在指定的 div 中。
我还使用 jQuery Multifiles 以便能够上传多个文件。这部分工作正常,我可以上传几个文件,这些文件会显示在服务器上。
这是我自己的 smicadminjavascripts.js
$(document).ready(function() {
$('#newticketform').bind('submit', function(e) {
e.preventDefault(); // <-- important
$(this).ajaxSubmit({
target: '#output'
});
});
});
我的 .html:
<html>
<head>
<script language='javascript' type='text/javascript' src='jquery-1.7.1.min.js'></script>
<script language='javascript' type='text/javascript' src='jquery.MultiFile.js'></script>
<script language='javascript' type='text/javascript' src='jquery.form.js'></script>
<script language='javascript' type='text/javascript' src='smicadminjavascripts.js'></script>
<head>
<body>
<form id='newticketform' enctype='multipart/form-data'method='POST'>
<input type='hidden' name='MAX_FILE_SIZE' value='1000000' />
<label for='title'>Rubrik</label> <input type='text' id='title' name='title'/><br/><br/>
<label for='description'>Beskrivning</label> <textarea rows='15' cols='50' id='description' name='description'></textarea><br/>
<!-- The file element -- NOTE: it has an ID -->
<input class='multi' id='my_file_element' type='file' name='file[]' maxlength='5' >
<div id='files_list'></div>
<input type='submit' name='upload' value='Upload' />
</form>
<div id='output'></div>
</body>
</html>
我的问题是什么以及如何解决它?
谢谢!
I am using jQuery Form to post data. I am sending some response from the server that I want present in the div specified with the target option. I can see in firebug that the response is actually returned to the browser but the information is not turning up in the specified div.
I'm also using jQuery Multifiles in order to be able to upload more than one file. This part works fine and I can upload several files and those are presented on the server.
This is my own smicadminjavascripts.js
$(document).ready(function() {
$('#newticketform').bind('submit', function(e) {
e.preventDefault(); // <-- important
$(this).ajaxSubmit({
target: '#output'
});
});
});
my .html:
<html>
<head>
<script language='javascript' type='text/javascript' src='jquery-1.7.1.min.js'></script>
<script language='javascript' type='text/javascript' src='jquery.MultiFile.js'></script>
<script language='javascript' type='text/javascript' src='jquery.form.js'></script>
<script language='javascript' type='text/javascript' src='smicadminjavascripts.js'></script>
<head>
<body>
<form id='newticketform' enctype='multipart/form-data'method='POST'>
<input type='hidden' name='MAX_FILE_SIZE' value='1000000' />
<label for='title'>Rubrik</label> <input type='text' id='title' name='title'/><br/><br/>
<label for='description'>Beskrivning</label> <textarea rows='15' cols='50' id='description' name='description'></textarea><br/>
<!-- The file element -- NOTE: it has an ID -->
<input class='multi' id='my_file_element' type='file' name='file[]' maxlength='5' >
<div id='files_list'></div>
<input type='submit' name='upload' value='Upload' />
</form>
<div id='output'></div>
</body>
</html>
What is my problem and how do I fix it?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我再次下载了 jquery.form (http://malsup.github.com/jquery.form.js ) 并替换了它。
但还是没用。问题是该文件没有再次下载到开发服务器(使用 NetBeans/ftp)。我必须再次选中该框才能下载它。
现在可以了。真的不知道真正的问题是什么。
I downloaded the jquery.form again (http://malsup.github.com/jquery.form.js) and replaced the it.
Still it didn't work. The problem was that the file wasn't downloaded to the development server again (using NetBeans/ftp). I had to check the box again in order to get it downloaded.
Now it works. Don't really know what the actuall problem was.