ajaxfileupload 半成品遇到的問題,不走success 走error的問題



大部分都是datatype 為 json的時候遇到的

1.遇到json被加pre標簽  去掉

2.遇到json被加audio 標簽 去掉

3.遇到json轉換錯誤,換方式轉


改后的代碼如下  , 有注釋

   
   
   
           
  1. uploadHttpData: function( r, type ) {
  2. var data = !type;
  3. data = type == "xml" || data ? r.responseXML : r.responseText;
  4. // If the type is "script", eval it in global context
  5. if ( type == "script" )
  6. jQuery.globalEval( data );
  7. // Get the JavaScript object, if JSON is used.
  8. if ( type == "json" ){
  9. //處理會加pre標簽
  10. if(data.indexOf('<pre>') != -1) {
  11. data = data.substring(5, data.length-6);
  12. }
  13. //處理會加audio標簽
  14. if(data.indexOf('<audio') != -1) {
  15. data = data.substring(0, data.indexOf('<audio'));
  16. }
  17. //改變原來的轉換json邏輯
  18. data = jQuery.parseJSON(data);
  19. }
  20. // evaluate scripts within html
  21. if ( type == "html" )
  22. jQuery("<div>").html(data).evalScripts();
  23. //alert($('param', data).each(function(){alert($(this).attr('value'));}));
  24. return data;
  25. }



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM