Here I will explain how to get JSON data from url in JavaScript or jQuery get JSON response from url in JavaScript.
In previous posts I explained Create Short urls using in javaScript, jQuery Get number of facebook likes, shares count for url, jQuery Google Currency Converter API Example and many articles relating to jQuery, JavaScript, asp.net. Now I will explain how to get JSON response or data from url in JavaScript.
<script type="text/javascript">
$(function()
{
$("#btnSubmit").click(function() {
$.getJSON("http://jsonip.appspot.com?callback=?",
function(data) {
alert("Your
IP Address: " + data.ip);
})
.error(function()
{ alert("error"); })
});
});
</script>
|
<script type="text/javascript">
function yourmethod(data) {
alert('City : '+data.city+' Country name : '+data.countryName);
}
</script>
<script type="text/javascript" src="http://smart-ip.net/geoip-json?callback=yourmethod"></script>
|
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|
Subscribe by RSS
Subscribe by Email
0 comments :