jQuery form plugin - Uncaught TypeError on file upload

徘徊边缘 提交于 2020-01-03 16:57:16

问题


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)  {...} 


回答1:


The latest version of jquery form doesn't use 'handelError'. Download it here: https://github.com/malsup/form/blob/master/jquery.form.js

UPDATE: The latest link is: https://github.com/jquery-form/form/blob/master/src/jquery.form.js



来源:https://stackoverflow.com/questions/6774231/jquery-form-plugin-uncaught-typeerror-on-file-upload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!