0

I am trying to get json data from a remote host with the following code. But failing, I am using jquery get json

my code

<script type="text/javascript" language="javascript">

$(document).ready(function() {
  $("#driver").click(function(event){
      $.getJSON('http://108.167.132.194/~softnet/json.php?callback=?', function(jd) {
         $('#stage').html('<p> Name: ' + jd.name + '</p>');
         $('#stage').append('<p>Password : ' + jd.password+ '</p>');

      });
  });
});

</script>

When i try to get data from localhost it works perfectly

h_h
  • 1,201
  • 4
  • 28
  • 47

2 Answers2

1

You should look into cross-domain ajax call. What you are trying to do will not work directly. You will either have to use JSONP or add the ips/hosts to allowed domain list.

What I can see from your client side code is that you are using JSONP but your server side does not support it. You need to implement it on also on the server side to support JSNOP.

Subir Kumar Sao
  • 8,171
  • 3
  • 26
  • 47
0

Your server needs to wrap the response in a callback so the browser doesn't instantly evaluate it. The callback parameter should then be set to the name of the callback that is returned.

Asad Saeeduddin
  • 46,193
  • 6
  • 90
  • 139