zoukankan      html  css  js  c++  java
  • 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. }


  • 相关阅读:
    vue-awesome-swiper
    兼容各浏览器到达顶部
    正则表达式
    设置当前窗口url中param的值
    IE8不支持的部分css3属性处理
    WebGL中的函数及内置属性介绍
    WebGL着色器
    cookie的存储
    如何处理一段字符串数据
    MUI框架
  • 原文地址:https://www.cnblogs.com/signheart/p/865d32d96c20834020773595cd7d291c.html
Copyright © 2011-2022 走看看