As per this documentation, AngularJS will strip off the prefix )]}',\n in the JSON responses. I am sending my JSON responses with the prefix in my JSON responses but AngularJS is not stripping off the prefix and interpreting the results. Any idea? Thanks.
I sent the responses back from Spring as described here. And it's sending JSON response with the prefix )]}',\n. In AngularJS, I need to retrieve the values:
var Retrieve = $resource('app/', {..});
and in the success call back function:
var successQuestions = function (q) {
$rootScope.q1 = q.question1;
};
I am expecting q JSON to be properly interpreted by AngularJS as a JSON but it is not.
I had the same problem, and noticed that the xhr object thought the response was null. The problem for me was that I had responseType: 'json' on the config of the request, so xhr was dropping the response before it ever got back to Angular since the response was not valid json.
Removing responseType: 'json' from the $http (or $resource in your case) request config fixed it for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With