使用ajax上传文件会引发未捕获的TypeError:非法调用

时间:2018-08-30 09:03:03

标签: javascript php jquery ajax ajaxform

使用的jquery版本是jquery 1.7.1 单击上翻按钮时,它显示错误为Uncaught TypeError:非法调用

$('#upload').on('click',function(){
    var form = new FormData();
    form.append('fw_file',$("#fw_file")[0].files[0]);
    $.ajax({
        url: base_url+'fieldwork/savefieldwork',
        cache: false,
        contentType: false,
        processData: false,
        dataType: 'json',
        type: 'POST', 
        data: form,
        success: function(data){

        }
    });
<form action="" method="post" accept-charset="utf-8" name="fieldworkform" id="fieldworkform" enctype="multipart/form-data">
<input type="file" name="fw_file" id="fw_file">
<input type="button" value="Upload" name="fileupload" id="upload">
</form>

0 个答案:

没有答案