I’m attempting to make a cross domain script call to get some JSON data from a remote server, I can see the request being made and the data being returned successfully using Fiddler, but the calls is failing because it is failing to parse the JSON – the JSON is valid…
Is there anything wrong with the following jquery ajax call?
jquery version = 1.7.1
$.ajax({
url: 'http://fooed.cloudapp.net/users?callback=?',
crossDomain: true,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
alert('success');
},
error: function(data) {
alert('error');
},
complete: function(xhr, data) {
if (xhr.status == 0)
alert('fail');
else
alert('success');
}
});
Example JSON:
[{ "ContentPreferences":[],
"Email":"mark.jones@somedomain.com",
"FirstName":"Mark",
"Id":"aa2f1944-e739-4329-9546-a21f52c02448",
"KnownAs":"Mark",
"LastName":"Jones",
"TimeStamp":"\/Date(1323804151906)\/"
}]
Your json is not valid jsonp. It should look like this instead:
That means that the api doesn’t support jsonp or requires a different param than
callback=?