1

Possible Duplicate:
JQuery won't get json?

<script type="text/javascript">
    var url = "http://local.yahooapis.com/LocalSearchService/V3/localSearch?appid=YahooDemo&query=pizza&zip=10504&results=2&output=json&callback=?";
    jQuery.getJSON(url, function (data) {
        alert(data);
    });
    var url1 = "http://services.odata.org/OData/OData.svc/Products?$format=json&callback=?";
    jQuery.getJSON(url1, function (data) {
        alert(data);
    });
</script>

By running the above code I am able to see first alert but not second. Can someone let me know the mistake over here ? The error I am receiving is "invalid label" in FF & expected ; in IE 8

Community
  • 1
  • 1
Karthik
  • 131
  • 1
  • 5

1 Answers1

5

The quest is actually using JSONP, which is what jQuery uses in the secret when it detects a parameter in the URL called callback.

Go to the url http://services.odata.org/OData/OData.svc/Products?$format=json&callback=xyzaxa and notice that the content doesnt contain the string xyzaxa, this means that a callback is never called from the service.

Either you are using a wrong URL, or odata doesent support JSONP

Kristoffer Sall-Storgaard
  • 10,576
  • 5
  • 36
  • 46