2012-09-12 27 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無法通過安全原因提交表單。我不得不讓用戶手動點擊文件輸入,然後表單插件做到了。