3

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.

1
  • can you bring example ? and show us what you do and what you expecting Commented Aug 11, 2014 at 19:33

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.