Jquery Get json from remote host

Posted by h_a86 on Stack Overflow See other posts from Stack Overflow or by h_a86
Published on 2012-10-20T16:40:00Z Indexed on 2012/10/20 17:01 UTC
Read the original article Hit count: 151

Hi i am trying to read json from a remote host by using this piece of code.

<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.getJSON("http://50.116.19.49/rest/user.json",function(result){
  $.each(result, function(i, field){
    $("div").append(field + " ");
      });
    });
  });
});
</script>
</head>
<body>

<button>Get JSON data</button>
<div></div>

</body>
</html>

The problem is when i type the url in browser i get json from it. But failed to get json by using the above jquery method.

Can someone help in this regard. Thanks

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery