Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/418.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法通过Ajax和firefox上载图像_Javascript_Php_Jquery_Html_Ajax - Fatal编程技术网

Javascript 无法通过Ajax和firefox上载图像

Javascript 无法通过Ajax和firefox上载图像,javascript,php,jquery,html,ajax,Javascript,Php,Jquery,Html,Ajax,我想通过Ajax上传图片到php脚本,但Firefox有一个例外 发出请求时出错:[Exception…”调用方法[NSInputStream::available]“nsresult:”0x8057030(NS_error_XPC_JSOBJECT_has_NO_FUNCTION_named)”位置:“JS frame::。send::line 8526”数据:否] 下面是我的Ajax代码: "Save": function() { jQuery.ajax({ url:

我想通过Ajax上传图片到php脚本,但Firefox有一个例外

发出请求时出错:[Exception…”调用方法[NSInputStream::available]“nsresult:”0x8057030(NS_error_XPC_JSOBJECT_has_NO_FUNCTION_named)”位置:“JS frame::。send::line 8526”数据:否]

下面是我的Ajax代码:

"Save": function() {
    jQuery.ajax({
        url: ajaxurl,
            timeout:30000,
            type: "POST",
            data: {
                'action':'update_mini',
                'postdata': JSON.stringify(new FormData(document.getElementById("mini_form"))),//jQuery('#mini_form').serialize(),
                'block': jQuery.urlParam('block')
            },
            enctype: 'multipart/form-data',        
            cache:false,
            processData: false,
            contentType: false,                                
            error: function(XMLHttpRequest, textStatus, errorThrown)  {
                alert("An error has occurred making the request: " + errorThrown)
            },
            success: function(data) {
                alert(data);                                        
                //jQuery("#mDialog").hide();
                //jQuery( this ).dialog( "close" );
            }
    });
以及Html表单代码:

<form id="mini_form" method="post">
    <fieldset>
        <label>Option Name :</label><br><input id="option" name="option" type="text"/>M<input id="m" name="m" class="minifield" type="text"/>P<input id="p" name="p" class="minifield" type="text"/><br>
 Image: <input type="file" name="image" id="image" />
    </fieldset>
</form>

选项名称:
MP
图片:

谢谢。

请将您的参数放入formdata中,尝试此选项

if (window.FormData) {
    formdata = new FormData();

    finput = document.getElementById("fileupload-input");
    file = finput.files[0];

    if (file && !!file.type.match(/image.*/)) {
        if (formdata) {
          formdata.append("image", file);

          upSuccess = true;

          jQuery.ajax({
            url: ajaxurl,
            type: "POST",
            data: formdata,
            processData: false,
            contentType: false,
            async: false,
            success: function(e){
                if (e == 'error'){ //an error occurred in server side script
                    alert('An error occured while uploading the image.');
                    upSuccess = false;
                }
            }
          });

          if (upSuccess == false){
            return;
          }
        }

    } 

}

尝试注释一些代码,看看是什么引起了这个错误,找到它后,更新问题