经过 4 个小时的阅读帖子尝试解决这个问题......
我使用该插件上传照片并将其返回到 Tinymce 编辑器。它在 Chrome 和 Firefox 中完美运行,但在 IE 中失败。在开发工具中,它在第 474 行的 jquery.forms.js 中中断,因为 IE 无法识别 finally
语句。因此,我将其删除,然后当同一个文件调用 form.submit()
时,我收到拒绝访问的消息。无论如何我都无法解决这个问题。我正在使用 Jquery v.1.8.1
和 Malsup 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);
}
}
任何帮助都可以挽救我的理智,谢谢!
最佳答案
事实证明这是100%不可能的。由于我通过触发的点击打开文件浏览器,而不是由实际用户点击按钮打开,因此出于安全原因,IE 将无法允许您提交表单。我必须让用户手动单击文件输入,然后表单插件就发挥了神奇作用。
关于Jquery 表单插件在 IE 8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12391249/