![](/img/trans.png)
[英]Stormpath-express login does not work with basic username:password authentication
[英]JQuery $.getJSON with username and password basic authentication?
我想要这样的东西: 如何在jQuery和AJAX中使用Basic Auth?
在这个问题中,他们解释了如何使用身份验证
我需要对服务器使用jQuery $.getJSON
而不是$.ajax
请求,因为它不支持跨站点。 而且我还需要提交用户名和密码。 有没有一种方法可以在$.getJSON
提交用户和密码作为参数, $.getJSON
无需像https://user:password@myserver.com
这样的URL发送它?
$ .getJSON是$ .ajax的简写,因此确实可能需要ajax。 您可以在http://api.jquery.com/jquery.ajax/上看到如何设置标题
$.ajax(url, {crossDomain:true, headers:{'X-My':'Foo'}})
$.getJSON("url", { user: "name", password: "123456" })
.done(function(json) {
console.log("Store User autthentication successfully");
})
.fail(function(jqxhr, textStatus, error) {
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.