I'm trying to do a get request to a website and get the response.
I'm able to do a successful HTTP request and response, but for some reason the javascript error pops up and it breaks my code.
I'm assuming it is because of the new query parameter it is appending, like http://checkip.amazonaws.com/?callback=jQuery152011860558553598821_1374187260201& _=1374187260214
Code here:
http://jsfiddle.net/R7EPt/191/
$('document').ready(function() {
var url = 'http://checkip.amazonaws.com/';
$.getJSON(url + "?callback=?", null, function(data) {
alert(data);
});
});
Could some one help me!
You are trying to issue a JSONP request from the client, but the server does not return a JSONP response. A JSONP response for the request checkip.amazonaws.com/?callback=foo
would look like this:
foo("192.168.0.1");
Instead of just this:
192.168.0.1
A solution to receive the user's IP via JSONP: Get user ip with jquery
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.