美文网首页
jq跨域问题解决(兼容ie8+)

jq跨域问题解决(兼容ie8+)

作者: 云桃桃 | 来源:发表于2018-11-20 09:32 被阅读5次

http://a.com 访问 http://b.com接口就属于跨域的情况。

 var opt = {
            type: "POST",
            dataType: "json",
            timeout: 20000,
            success: function (data) {
                if (successCallback) {
                    successCallback(data);
                }
            },
            error: function (e) {
                if (errorCallback) {
                    errorCallback(e);
                }
            }
        };
        // 跨域问题解决  在请求之前加上这句就够了
        $.support.cors = true;


        $.extend(opt, option);
        $.ajax(opt);

相关文章

网友评论

      本文标题:jq跨域问题解决(兼容ie8+)

      本文链接:https://www.haomeiwen.com/subject/snhtqqtx.html