封装了jQuery的Ajax请求全局配置

2020-05-22 17:05:11易采站长站整理

            if((requestType === ‘json’ || requestType === “jsonp”) && typeof(data) === “string”) {
                data = JSON.parse(data);
            }
            if(data.success) {
                opt.success(data);
            }

            if(opt.error) {
                opt.error(data);
            }

        },
        error: function(xhr, status, handler) {
            if (opt.error)
                opt.error();
        }
    };
};
function unescapeEntity(str) {
    var reg = /&(?:nbsp|#160|lt|#60|gt|62|amp|#38|quot|#34|cent|#162|pound|#163|yen|#165|euro|#8364|sect|#167|copy|#169|reg|#174|trade|#8482|times|#215|divide|#247);/g,
        entity = {
        ‘ ‘   : ‘ ‘,
        ‘ ’   : ‘ ‘,
        ‘<‘     : ‘<‘,
        ‘<’    : ‘<‘,
        ‘>’     : ‘>’,
        ‘&62;’     : ‘>’,
        ‘&’    : ‘&’,
        ‘&’    : ‘&’,
        ‘"’   : ‘”‘,
        ‘"’    : ‘”‘,
        ‘¢’   : ‘¢’,
        ‘¢’   : ‘¢’,
        ‘£’  : ‘£’,
        ‘£’   : ‘£’,