Introduction:
Here I will explain how to get JSON data from url in JavaScript or jQuery get JSON response from url in JavaScript.
Here I will explain how to get JSON data from url in JavaScript or jQuery get JSON response from url in JavaScript.
Description:
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.
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.
To
get JSON data or response
from url in JavaScript
we can write in different ways like as shown below
Method 1:
<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>
|
For
complete example check this post Get IP Address of Client Machine in jQuery
Method 2:
<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>
|
For
complete example check this post Get User IP Address, Latitude, Longitude, Country, City Details
in jQuery
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. |
|||
|
|||
1 comments :
How do you do this for https url?
I need to pass client certificates along with URL.. But I am getting 500 Internal error.
Please help me on this
Note: Only a member of this blog may post a comment.