2012-09-12 26 views
8

不工作4小时阅读帖子后,试图解决这个问题.....jQuery的形式插件的IE 8

我使用该插件上传照片,并返回到TinyMCE的编辑器。它适用于Chrome和Firefox,但在IE中失败。在开发工具中,由于IE无法识别finally语句,因此它在474行的jquery.forms.js中断。所以我删除它,然后我收到访问被拒绝,当相同的文件调用form.submit()。不管我不能解决这个问题。我正在使用Jquery v. 1.8.1Malsup Jquery Form Plugin v. 3.15

下面是代码:

$("#img-form").hide(); // hide the browse button 

$("#image").change(function() { 
    $("#img-form").ajaxSubmit(options); // upload the file directly after selection 
}); 


/* 
* set options for jQuery form plugin 
*/ 
var options = { 
    cache: false, 
    contentType:"text/html", 
    type: 'POST', 
    url: "../upload.php", 
    data: { width: w, height: h, bounds: b }, 
    success: showResponse // post-submit callback 
}; 

function showResponse(responseText, statusText, xhr, $form) { 
    var obj = JSON.parse(responseText); 
    var state = obj.state; 
    var response = obj.response; 

    if(state) { 
     tinyMCE.execCommand('mceInsertContent', false, response); // place the image into the editor 
    } else { 
     alert(response); 
    } 
} 

任何帮助都,你会救我的理智,谢谢!

回答

6

事实证明这是100%不可能的。由于我通过触发click打开文件浏览器,而不是由实际用户单击该按钮,因此IE无法通过安全原因提交表单。我不得不让用户手动点击文件输入,然后表单插件做到了。