I’m new to javascript/jquery.
I have the following basic code and I keep receiving the “error” alert message:
var jqxhr = $.get('my_url',
function(data) {
alert("success");
})
.success(function() {
alert("second success");
})
.error(function() {
alert("error");
})
.complete(function() {
alert("complete");
});
Note that if I copy and paste my_url in the browser I get an xml file back. What am I doing wrong? How can I get a detailed error description??
Your error:
indicates that you have a same origin issue. You cannot do ajax calls to a domain that is different than the domain of the host web page.
See this MDN reference for more info on same origin on the same origin policy.
A work-around is to use JSONP (which uses script tags which are not subject to the same origin policy), but this requires changing the server to support JSONP for this operation.