Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Get JSON Data/Response From URL in JavaScript

Feb 24, 2013
Introduction
  
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 jQueryJavaScript, 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>

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 RSS subscribe by email Subscribe by Email

1 comments :

Anonymous said...

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

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.