大部分都是datatype 為 json的時候遇到的
1.遇到json被加pre標簽 去掉
2.遇到json被加audio 標簽 去掉
3.遇到json轉換錯誤,換方式轉
改后的代碼如下 , 有注釋
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" ){
//處理會加pre標簽
if(data.indexOf('<pre>') != -1) {
data = data.substring(5, data.length-6);
}
//處理會加audio標簽
if(data.indexOf('<audio') != -1) {
data = data.substring(0, data.indexOf('<audio'));
}
//改變原來的轉換json邏輯
data = jQuery.parseJSON(data);
}
// evaluate scripts within html
if ( type == "html" )
jQuery("<div>").html(data).evalScripts();
//alert($('param', data).each(function(){alert($(this).attr('value'));}));
return data;
}