$.ajax({
url: 'http://handshake.aid-dcc.asia/api/customer/get_user_list',
type: 'POST',
cache: true,
dataType: 'json',
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", 'Basic J25hbWFwcDpKbTZzdUdyayc=')
},
sucess: function(result) {
alert('done');
}
});
My problems are:
I load json file from url: http:handshake.aid-dcc.asia/api/customer/get_user_list. But The link will require username + pass when we open it. So, I used "Authorization" with EncodeBase64('username:password') in my code. I received some errors:
- OPTIONS http:handshake.aid-dcc.asia/api/customer/get_user_list 401 (Authorization Required)
- XMLHttpRequest cannot load http:handshake.aid-dcc.asia/api/customer/get_user_list. Origin http:localhost is not allowed by Access-Control-Allow-Origin.
What's wrong with my code?