dataType为json会报Uncaught TypeError: jQuery.handleError is not a function
报错截图:
返回数据:
data = "<pre style="word-wrap: break-word; white-space: pre-wrap;">{"time":"0.473S","resultMsg":"操作成功","resultFlag":"00","isFullMatch":"","result":[],"input":[]}</pre>"
不是json类型的,所以去ajaxfileupload.js源码里加了截取字符串后,返回数据如下
data = Object {time: "0.435S", resultMsg: "操作成功", resultFlag: "00", isFullMatch: "", result: Array[0]…}, status = "success"
ajaxfileupload.js源代码中uploadHttpData:
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" )
eval( "data = " + data );
// evaluate scripts within html
if ( type == "html" )
jQuery("<div>").html(data).evalScripts();
return data;
}
type等于json时添加截取字符串操作:
// Get the JavaScript object, if JSON is used.
if ( type == "json" )
data = r.responseText;
var start = data.indexOf(">");
if(start != -1) {
var end = data.indexOf("<", start + 1);
if(end != -1) {
data = data.substring(start + 1, end);
}
}
eval( "data = " + data );
另外:
当dataType改为text时不会报这个错,但是返回时进入不了success,当加了上面的代码后也能成功进入success