1

I've got this in my code:

 .getJSON("http://myUrl.com", function(data){ alert("callback being called");});

Using a break point in my server side code I can see the jSON stream being returned from the url. Stepping through in Chrome I never see the alert invoked (or any other code inside there). When I look at the network traffic using the chrome developer tools I see that the call is being made to myURl (and I can see the response as the jSON string I'm expecting). It just appears the call back function is never executing.

Anyone have an idea of why it wouldn't be executing?

Sotiris
  • 38,986
  • 11
  • 53
  • 85
tad604
  • 336
  • 1
  • 5
  • 18

3 Answers3

1

I had several issues most of which were resolved by digging a little deeper on here (my bad but maybe this can help others still).

  1. I wasn't returning the right content type (application/json)
  2. My json wasn't parsing correctly (I had a semi-colon at the end and extra commas at the end of array declarations http://paulisageek.com/json_validator/ helped validate my json.
  3. using the .ajax() method with the error binding also helped me trouble shoot my issues.

Was frustrating because no exceptions/errors were thrown it just refused to call the callback.

tad604
  • 336
  • 1
  • 5
  • 18
0

you can check the POINT NO 2 with in this tutorial - link

http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/

Vikas Naranje
  • 2,350
  • 5
  • 30
  • 40
0

Try the following first and then replace with your URL

<script type="text/javascript">
    $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?",
    function (data) { alert("callback being called");}
    );
</script>
Nicholas Murray
  • 13,305
  • 14
  • 65
  • 84