0

I have a valid JSON file on domain example1.com. It's just a PHP file with a header ('Content-type: application/json; charset=utf-8'). The JSON on this page is valid.

I'm trying to parse the JSON on another domain. This is the script:

$(function() {
    $.getJSON('www.example1.com?callback=?', function(data) {
        alert("lol")
    });
});

Why is the alert not working? It seems like the callback is never launched.

flavian
  • 28,161
  • 11
  • 65
  • 105

2 Answers2

0

I think the json is bad from that url you're getting.

does it have echo "{}" ?

or echo json_encode($something) ?

it needs to return an empty json, or some json

Jacek Pietal
  • 1,980
  • 1
  • 18
  • 27
0

Had to put http:// in the url.

http://www.example1.com?callback=?