嗨,我使用 ajax 实现了文件上传功能,并且我将 ajax 设置为这种实现的同步类型我在我的 ctp 文件中使用了以下 jQuery 文件(我在我的 default.ctp 中遵循了 cakePHP 设计模式,我使用了 jquery 1.4)
'jquery-1_7.js','jquery.form.js','jquery-ui_1_9_1.js'
并且在Firefox中一切正常,来到IE它不起作用我的代码片段如下
var options = {
complete: function(response) {
var fileObj = jQuery.parseJSON(response.responseText);
var fileId = fileObj.FileNo;
var elemNo = fileId.replace('file', '');
if(fileObj.Txt == 'SUCCESS'){
//copy the id into global; variable
}
},
error: function(response) {
//display error
}
};
ajax 调用
$('#sBtn').button().click(function(){
$.ajaxSetup({async:false});
files = []; //globalvaraiable
for(i=0; i<fileCnt; i++){
if ($('#addFile'+i).length > 0) {
$('#addFile'+i).ajaxForm(options);
$('#addFile'+i).submit();
window.setTimeout($('#addFile'+i).bind($('#addFile'+i)), 100); console.log(files);
}
}
$('#ContentId').ajaxForm($('input#contentIds').val(files));
$('#ContentId').submit();
$('#loadingImg').addClass('clear');
}
return false;
});
在 IE 中我收到以下错误
SCRIPT438: Object doesn't support property or method 'push'
jquery-1_7.js, line 3008 character 5