I am trying to retrieve information from my Chargify test account but I am getting two errors: 401 (which disappears after "authenticating") and then I get 404 which I do not understand since it works on my browser after authenticating.
I am not really good with web coding so I am sure that is the problem. What i am using to try and get the data from the URL is this:
$.ajax({
type: "GET",
url: "https://testingtests.chargify.com/customers.json",
dataType: "json",
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', make_base_auth("someusername", "somepassword"));
},
success: function (response) {
alert(response.d);
},
failure: function (response) {
alert(response.d);
},
})
function make_base_auth(user, password) {
var tok = user + ':' + password;
var hash = btoa(tok);
return 'Basic ' + hash;
}
EDIT: I just read that the problem seems to be that one cannot do cross domain access and that I would have to use cURL but I have not found anything on how to use it.