AJAX - JQuery GET Callback not working but JSON file access ok AJAX - JQuery GET Callback not working but JSON file access ok ajax ajax

AJAX - JQuery GET Callback not working but JSON file access ok


I'm not entirely sure what your problem is, if you get a result but the console stays quiet you could have issues with the JSON itself... try JSONLint to find issues.

Also I would recommend you don't use getJson etc.

$.ajax({    url: http://files.mysite.com/data.json,    dataType: 'jsonp',    cache: false,    beforeSend: function () {        console.log("Loading");    },    error: function (jqXHR, textStatus, errorThrown) {        console.log(jqXHR);        console.log(textStatus);        console.log(errorThrown);    },    success: function (data) {        console.log('Success');        console.log(data);    },    complete: function () {        console.log('Finished all tasks');    }});

This way you get some error handling and other nice little features, you could add a loading spinner via beforeSend, and remove it via complete :)

Edit:Replace the error function with the one below, that should give us a better idea of what the problem is :)

error: function (jqXHR, textStatus, errorThrown) {  console.log(jqXHR);  console.log(textStatus);  console.log(errorThrown);}


jsonp is not supported see here, only xml, json, script, htmlso use json instead if you dont have cross domain policy issue

$.get('http://files.mysite.com/data.json', function(data) {    console.log(data);}, "json");


Its better to use $.getJSON instead of get if you know that the response will be json. The console should work now

$.getJSON('http://files.mysite.com/data.json', function(data) { console.log(data);});