Reputation: 143
I'm just trying to get a user's IP address via jQuery/JSONP and had success with other services but I cannot determine why the callback is not called when using hostip.info's JSON API
Firebug and Fiddler both show the JSON response data I am expecting but success is never called and the error is a parse error so I must be missing something.
Any thoughts or suggestions would be great. Thanks in advance.
Simple code:
$.ajax({
type: "GET",
url: "http://api.hostip.info/get_json.php",
dataType: "jsonp",
success: function(json) {
alert(json.ip);
},
error: function (request, type, status)
{
alert('[request: ' + request.statusText + '] [type: ' + type + '] [status: ' + status + ']');
}
});
Upvotes: 1
Views: 536
Reputation: 97717
The service is json not jsonp, change dataType
to json
, see http://jsfiddle.net/wdqeV/3/
Upvotes: 3