This is a cross-domain AJAX request to my web service.
$(document).ready(function(){
$.ajax({
url: 'http://storage.loc/api/getowners/?host=http://www.mail.ru/&callback=parseJSON',
dataType: 'jsonp',
crossDomain: true,
type: 'GET',
jsonp: false,
jsonCallback: 'parseJSON',
error: function(){
alert('Error');
},
complete: function(jqXHR, textStatus){
alert(textStatus);
}
});
});
function parseJSON(data)
{
var links = [];
$.each(data.users, function(key,value) {
links.push = '<a href="#" id="'+value+'"onClick="getData(this)">'+value+'</a><br />';
});
}
The response is:
parseJSON({"users":{"user0":"rulezz87","user1":"karazyab"}})
The response seems to be correct, but textStatus is “parsererror” and array in parseJSON() is empty. I`m not a pro in jQuery, so can you tell me, what i did wrong?
The response is incorrect sinde the list of users is not an array. It should be like:
So, the error message is correct and the fact that it cannot parse from JSON also.