第一次使用ajaxFileUpload,据说,当年使用的jQuery还是1.9,好多年没更新了,而我。。。第一次使用jQuery就4.0了。
出现这个错误的原因是ajaxfileupload内部少了handleError方法,这个方法应该是jQuery版本里面的。So,copy一份过来ajaxfileupload.js内。
如下面红色部分是copy进来的,即在ajaxfileupload内如下添加红色部分:
// JavaScript Document
jQuery.extend({
//添加内容↓
handleError : function(s, xhr, status, e) {
// If a local callback was specified, fire it
if (s.error) {
s.error.call(s.context || s, xhr, status, e);
}
// Fire the global callback
if (s.global) {
(s.context ? jQuery(s.context) : jQuery.event).trigger(
"ajaxError", [ xhr, s, e ]);
}
},
//添加内容↑
createUploadIframe :function(id, uri) {
// create frame
var frameId ='jUploadFrame' + id;
if (window.ActiveXObject) {
var io = document.createElement('<iframe id="' + frameId
+'" name="' + frameId + '" />');
if (typeof uri =='boolean') {
io.src ='javascript:false';
}elseif (typeof uri =='string') {
io.src = uri;
}
}else {
var io = document.createElement('iframe');
io.id = frameId;
io.name = frameId;
}
io.style.position ='absolute';
io.style.top ='-1000px';
io.style.left ='-1000px';
document.body.appendChild(io);
return io;
},
参考链接:http://zhangzhaoaaa.iteye.com/blog/2123021