Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
185
rated 0 times [  191] [ 6]  / answers: 1 / hits: 13790  / 11 Years ago, wed, december 18, 2013, 12:00:00

I am using below code to access rest service hosted on another domain.



$.ajax({
type: 'GET',
url: url,
async: false,
jsonpCallback: 'jsonCallback',
contentType: application/json,
dataType:jsonp,
success: function(json) {
alert(json);
},
error: function(e) {
console.log(e.message);
}
});


I am able to get the data correctly, but I get this error in firebug in mozilla:




SyntaxError: missing ; before statement



{Hello:World}




Can anyone suggest me what I am doing wrong here? Even though Json data is valid. I tried all the suggestions posted in this question But still I am getting same error.


More From » jquery

 Answers
50

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);
}
});

[#49410] Wednesday, December 18, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mariamiyanab

Total Points: 75
Total Questions: 102
Total Answers: 92

Location: British Indian Ocean Territory
Member since Tue, Feb 22, 2022
2 Years ago
;