各位大大,我从网站api看到用 HTTP Basic Auth 认证
他们提供的范例
curl "https://api.livechatinc.com/V2/agents" \
-u user:password \
-H X-API-Version:2
请问我要怎么用 JQ ajax 自动认证,他都会一直要我打帐号密码。
以下是我写的 http://jsfiddle.net/18pz8era/
$.ajax({
type: "POST",
url: 'https://api.livechatinc.com/V2/agents',
dataType: "jsonp",
success: function(msg){
alert(JSON.stringify(msg));
},
error: function() {
alert("ERROR!!!");
}
});