views:

3771

answers:

2
+6  A: 

It's not returning the callback function, so it cannot be evaluated.

You should have something like this in your PHP code:

echo $_GET['callback'] . '(' . $jsonData . ');';

Hah, oh sorry, if you were using php, that would be the case.

You want that in your javascript file, and you're going to need to specify a hardcoded callback instead because it's a static list.

See: http://www.ibm.com/developerworks/library/wa-aj-jsonp1/

altCognito
+4  A: 

altCognito is correct. Here is a working example:

Put this in the top of your page you are calling from, in the

$.getJSON("http://www.yourotherdomain.com/testcross.php?jsoncallback=?",
    function(data){
      $('body').html(data.name).css("color","green");  
    });

and the php that would return stuff:

  $data = '{"name" : "hello world"}';
  echo $_GET['jsoncallback'] . '(' . $data . ');';
Thomas