I'm having trouble retrieving JSONP data from one of my sites. On Site A data is being provided by the following MVC2 controller action:
public JsonResult JsonList(string key) {
var consultants = rep.FindAll().Where(c => c.IsActive).Select(c => new ConsultantJsonItem { Firstname = c.Firstname, Surname = c.Surname });
return Json(consultants, "application/json");
}
On Site B, I'm using jQuery to retrieve the JSON, like this:
$.ajax({
url: 'http://www.siteA.com/controller/jsonaction/',
dataType: 'JSONP',
crossDomain: true,
success: function (json) {
alert("success"); // THIS DISPLAYS
alert(json); // THIS IS ALWAYS EMPTY
},
error: function (xhr, status, error) {
alert(status); // NOT CALLED
}
});
I can see in the Firebug console that the response completed correctly with a 200 code, and I can see that the content length of the response is 11516 bytes, yet the response tab is completely empty and jQuery will not give me any data to work with.
Can anyone tell me why this is?
Note: This site is using jQuery 1.4.2