How To Resolve Uncaught Syntax Error In Jsonp
I am accessing a cross domain api using jquery ajax but I can't achieve it . Iam getting error as 'uncaught syntaxerror : unexpected token <' in the console, How to fix this. Co
Solution 1:
You cannot make cross domain AJAX calls using JSONP to a server that returns XML. If you want to be able to make a cross domain AJAX call you have 2 possibilities:
- use
JSONP
-> your server needs to support it. - use
CORS
-> your server AND client browser need t support it.
If your server supports CORS your request may look like this:
$.ajax({
url: "http://..............",
type:"GET",
crossDomain: true,
success: function (data) {
alert(data);
},
error: function (errorMEssage, Errtext) {
alert(Errtext);
}
});
Solution 2:
change the dataType to xml
dataType: 'xml',
Post a Comment for "How To Resolve Uncaught Syntax Error In Jsonp"