I am writing code that runs on an https://
page. I want to communicate with an http://
page from my page.
I am using following code:
var USERNAME = "*****";
var PASSWORD = "****"
$.ajax({
type: "POST",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
headers: {
"Authorization": encodeURI("BASIC " + btoa(USERNAME + ":" + PASSWORD))
},
url: "http://111.93.214.93/data",
data: JSON.stringify(data)
})
.done(function(response) {
alert("Shuffled image successfully")
})
.fail(function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR, textStatus, errorThrown);
alert("Server Error");
})
.always(function(jqXHROrData, textStatus, jqXHROrErrorThrown) {});
Is this right the method to call?
I am getting a "404 Not Found" error.
I have tried this also. but it is not helping
type: "POST",
contentType: 'application/json; charset=utf-8',
async:false,
crossDomain: true,
callback: '?',
dataType: 'jsonp',
headers: {
"Authorization": "Basic " + btoa(unescape(encodeURIComponent(USERNAME + ":" + PASSWORD)))
},