jquery - jsonp callback problem -


i'm trying following code retrieve client ip, , works fine

<script type="text/javascript">       function getip(json) {         var ip = json.ip; // alerts client ip address         alert(ip);     } </script> <script type="text/javascript" src="http://jsonip.appspot.com/?callback=getip"></script> 

but when try $.ajax nothing...

    $.ajax({         type: "get",         url: 'http://jsonip.appspot.com/?callback=getip',         datatype: "jsonp",                     success: function getip(json) {             alert("sucess");             var ip = json.ip;             alert(ip);         }      });  }); 

plz help

$.ajax({     type: "get",     url: "http://jsonip.appspot.com/?callback=?",     //                                        ^     // ---- note ? symbol ----------------|     // jquery responsible replacing symbol     // name of auto generated callback fn     datatype: "jsonp",     success: function(json) {         var ip = json.ip;         alert(ip);     } }); 

jsfiddle demo here.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -