更新时间:2023-09-13 15:32:46
您需要设置相应的请求标头以传递凭据。例如,请参阅此处。
You will need to set the appropriate request header to pass the credentials. For example see here.
$.getJSON({
'url': 'http://host.com/action/',
'otherSettings': 'othervalues',
'beforeSend': function(xhr) {
//May need to use "Authorization" instead
xhr.setRequestHeader("Authentication",
"Basic " + encodeBase64(username + ":" + password)
},
success: function(result) {
alert('done');
}
});
仅供参考我在Google搜索 jquery post with basic auth
,这是第一个链接。
FYI I searched Google for jquery post with basic auth
and this was the first link.