jeudi 6 août 2015

JSON.parse empty response in Ember

In my Ember project, I use the following code to get a JSON response from my back-end:

Ember.$.getJSON(
    http://ift.tt/1MSvtgC,
    function (data) {
        console.log(data);
});

And there, I get the following error message: SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data.

My back-end is written in PHP using Symfony, and VoryxRESTGeneratorBundle to send JSON. When I visit http://ift.tt/1MSvtgC on my browser, I get a nice JSON response:

{
    "links": 
    [
    {
        "id": 28,
        [...]
    }
    ]
}

It looks like the answer is not correctly detected when using Ember. I'm unsure if the problem comes from back or front-end. How should I fix this?

Additional information:

This code in Ember generate a OPTION request, with an empty 200 response:

Ember.$.ajax({
    url: http://ift.tt/1MSvtgC,
    type: 'GET',
    contentType: 'application/json'
});




Aucun commentaire:

Enregistrer un commentaire