ajaxfileupload 半成品遇到的问题,不走success 走error的问题
大部分都是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 contextif ( 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 htmlif ( type == "html" )jQuery("<div>").html(data).evalScripts();//alert($('param', data).each(function(){alert($(this).attr('value'));}));return data;}
浙公网安备 33010602011771号