Gio*_*ato 4 javascript authentication ajax jquery cors
我已经阅读了很多有关CORS和身份验证的文档,而且我很确定可以正确执行操作。我正在尝试验证jQuery.ajax GET CORS请求,如下所示:
$.ajax('http://httpbin.org/basic-auth/foo/bar', {
type: 'GET',
username: 'foo',
password: 'bar',
xhrFields: {
withCredentials: true
}
}).then(function (data) {
alert('success');
}, function (xhr) {
alert('failure');
});
Run Code Online (Sandbox Code Playgroud)
但浏览器不断提示我输入凭据,而不发送所提供的凭据。在http://jsfiddle.net/BpYc3/上尝试此操作,其中http://httpbin.org应该发送正确的CORS标头。
检查这个出来。
如果您的服务器要求提供凭据,那么您将无法使用
Access-Control-Allow-Origin: *
Run Code Online (Sandbox Code Playgroud)
使用通配符:您必须指定允许的域。
| 归档时间: |
|
| 查看次数: |
4400 次 |
| 最近记录: |