1、 加载报错: ajaxfileupload.js:1 Uncaught ReferenceError: jQuery is not defined
上传报错: Uncaught TypeError: $.ajaxFileUpload is not a function
原因: jquery.js,ajaxfileupload.js加载顺序不正确,应先加载 jquery.js,再加载ajaxfileupload.js


2、 运行时报错: jQuery.handleError is not a function
原因: ajaxfileupload.js插件中使用低版本jquery,版本1.4.2之前的版本才有handlerError方法,例子里使用的Jquery是1.2的,需手动添加该方法

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] );
}
}

3、 执行成功后,始终指向error方法处理,无法执行sucess方法
原因: 这个是由于ajaxfileupload.js 处理返回data的时候,没有考虑后台返回的是字符串的问题,data数据被加了pre标签了。。。

uploadHttpData: function (r, type) {
var data = !type;
data = type == "xml" || data ? r.responseXML : r.responseText; // If the type is "script", eval it in global context
if (type == "script")
jQuery.globalEval(data); // Get the JavaScript object, if JSON is used.
if (type == "json")
data=data.replace("

","").replace("
",""); //如果返回的是字符串(JSON格式字符串),去除pre标签
data=eval('(' + data+ ')'); // evaluate scripts within html
return data;
if (type == "html")
jQuery("
").html(data).evalScripts();
return data;
}