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