CORS jQuery AJAX请求在Chrome中请求凭据而不在其他浏览器中工作

时间:2017-08-10 18:01:25

标签: jquery ajax cors xss

我遵循在ready内调用的ajax请求。

$.ajax({
        url: 'http://otherurl.com',
        username: 'user',
        password: 'pwk',
        type: 'GET',
        xhrFields: {
            withCredentials: true
        },
        crossDomain:true,
        dataType:"json",            
        success: function (data) {
            console.log(data)
        },
        error: function (a, b, c) {
            console.log("a", a);
            console.log("b", b);
            console.log("c", c);
        }
    });

当我在chrome中打开页面时,请求会转到服务器,我会看到弹出窗口提供用户名和密码(提供的凭据无效)。如果我输入凭据一次,ajax请求之后工作正常,直到我清除浏览历史记录。

在Firefox和IE中,ajax请求永远不会发送到服务器,并始​​终以ready = 0的错误回调结束。我怎么解决这个问题?

0 个答案:

没有答案