Why jQuery consider an 200 response Ajax request with empty content as fail()?

前端 未结 2 1165
温柔的废话
温柔的废话 2020-12-31 06:30

First, there\'s no cross-region problem at all.

I found if the server response an empty content body, jQuery consider this as fail()?

Why is this?

2条回答
  •  旧巷少年郎
    2020-12-31 07:04

    If you're using jQuery >= 1.9 an empty JSON response will be rejected, according to the API documentation:

    The JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. As of jQuery 1.9, an empty response is also rejected; the server should return a response of null or {} instead.

提交回复
热议问题