jQuery表单插件 - 在文件上传时未捕获TypeError [英] jQuery form plugin - Uncaught TypeError on file upload
本文介绍了jQuery表单插件 - 在文件上传时未捕获TypeError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $返回新的d.fn.init(a,b,g)}没有方法'handleError'
这里是我的代码,
< form id =employeeaddformclass =classformenctype =multipart / form-data action =inc / employeeadd.phpmethod =post>
< p>< input type =filesize =32name =my_fieldvalue =/>< / p>
< p class =button>< input type =hiddenname =actionvalue =image/>
< label for =nname>个人名称:< / label>
< input name =nnameid =nnametype =texttabindex =11/>
< br />
< label for =ninformation>信息:< / label>
< div align =center>
< input id =button1type =submit/>
< input id =button2type =reset/>
< / div>
< / form>
< script type =text / javascript>
$(document).ready(function(){
var options_employeeadd = {
beforeSubmit:validate_employeeadd,//预先提交回调
成功:showResponse_employeeadd //提交后回调
};
$('#employeeaddform')。ajaxForm(options_employeeadd);});
函数validate_employeeadd(formData,jqForm,options){...}
函数showResponse_employeeadd(responseText,statusText,xhr,$ form){...}
解决方案
最新版本的jQuery表单不使用'handelError'。在这里下载: https://github.com/malsup/form/blob/master/jquery。 form.js
there is no problem when I don't select any file for upload, when I just fill the other inputs than post form, It's working. but when I choose a file for image upload than post it, I'm getting this error, but when I look folder, I see that file uploaded. but javascript failed.
jquery.form.js:357 Uncaught TypeError:
Object function (a,b){return new d.fn.init(a,b,g)} has no method 'handleError'
here is my code,
<form id="employeeaddform" class = "classform" enctype="multipart/form-data" action="inc/employeeadd.php" method="post">
<p><input type="file" size="32" name="my_field" value="" /></p>
<p class="button"><input type="hidden" name="action" value="image" />
<label for="nname">Personal Name : </label>
<input name="nname" id="nname" type="text" tabindex="11" />
<br />
<label for="ninformation">Information : </label>
<textarea id="ninformation" name="ninformation"></textarea>
<div align="center">
<input id="button1" type="submit"/>
<input id="button2" type="reset" />
</div>
</form>
<script type="text/javascript">
$(document).ready(function(){
var options_employeeadd = {
beforeSubmit: validate_employeeadd, // pre-submit callback
success: showResponse_employeeadd // post-submit callback
};
$('#employeeaddform').ajaxForm(options_employeeadd); });
function validate_employeeadd(formData, jqForm, options) {...}
function showResponse_employeeadd(responseText, statusText, xhr, $form) {...}
解决方案
The latest version of jquery form doesn't use 'handelError'. Download it here: https://github.com/malsup/form/blob/master/jquery.form.js
这篇关于jQuery表单插件 - 在文件上传时未捕获TypeError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文