SyntaxError: Missing ; Before Statement Jquery Jsonp
I am using below code to access rest service hosted on another domain. $.ajax({ type: 'GET', url: url, async: false, jsonpCallback:
Solution 1:
If it's really JSON you ask for, don't set "jsonp"
as dataType
, and don't provide a callback :
$.ajax({
type: 'GET',
url: url,
contentType: "application/json",
success: function(json) {
alert(json);
},
error: function(e) {
console.log(e.message);
}
});
Solution 2:
the format of JSON and JSONP are slightæy different JKSONP is a function invocation expression
callback({"hellow":"world"});
whereas JSON is simply a serialized object
{"Hello":"world"}
fromyour posting it would seem that the server is returning JSON and not JSONP
So you either need to change the server to reply correctly (The actual callback name is a get parameter to the request). You should do this if you are using the ajax call across domains
If you are not using ajax across domains stick to regular JSON
Post a Comment for "SyntaxError: Missing ; Before Statement Jquery Jsonp"