AngularJS $ http prefix not missing

According to this documentation , AngularJS will disable the prefix )]}',\n

in JSON responses. I am sending JSON responses with a prefix in my JSON responses, but AngularJS does not strip the prefix and does not interpret the results. Any ideas? Thank.

I've posted responses from Spring as described here . And it sends a JSON response with a prefix )]}',\n

. In AngularJS, I need to get the values:

var Retrieve = $resource('app/', {..});

      

and in the call return function:

var successQuestions = function (q) {
    $rootScope.q1 = q.question1;
};

      

I expect q JSON to be correctly interpreted by AngularJS as JSON, but it is not.

+3


source to share


1 answer


I had the same problem and noticed that the xhr object thinks that the answer was null. The problem for me was what I had responseType: 'json'

in the request config so the xhr was throwing away the response before it ever came back to Angular since the response was invalid json.



Removing the responseType: 'json'

$ http (or $ resource in your case) request from the configuration fixed it for me.

+3


source







All Articles