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

My code is as follows:

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

When I look in the menu Networkfrom Firebug, I see a valid call in my file JSON, and when I open it, it contains all the information.

But it Consoleremains silent. No sign of a call AJAXand my logging data.

My call is AJAXnot in the same domain as mine JSON. That's why i usejsonp

Any ideas?

+5
source share
3 answers

, , , , JSON... try JSONLint, .

getJson ..

$.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');
    }
});

, , beforeSend ::)

: , , :)

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

$.getJSON get, , json.

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

jsonp , xml, json, script, html json json,

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

All Articles