XMLHTTPRequest responseBody vs responseText

I always referred to the body property in the XMLHTTPRequest response, because it is always a good, useful parsed js object. But this time, the body is null, and the answer sits there in a string in .text, and I would like to know why this could be, and the tradeoffs of using one over the other in the interactions between the server and the client.

+5
source share
1 answer

The server responds with an invalid Content-Type header. Make sure it is set to something sensible, like application/json .

+4
source

Source: https://habr.com/ru/post/1242333/


All Articles