更新时间:2021-11-23 21:39:00
Content-Type
标题仅用作应用程序的信息。浏览器并不关心它是什么。浏览器只返回AJAX调用中的数据。如果你想把它解析为JSON,你需要自己做。
The Content-Type
header is just used as info for your application. The browser doesn't care what it is. The browser just returns you the data from the AJAX call. If you want to parse it as JSON, you need to do that on your own.
标题就在那里,所以你的应用程序可以检测返回了什么数据以及它应该如何处理它。您需要查看标题,如果它是 application / json
,则将其解析为JSON。
The header is there so your app can detect what data was returned and how it should handle it. You need to look at the header, and if it's application/json
then parse it as JSON.
这是实际上jQuery是如何工作的。如果您不告诉它如何处理结果,它会使用 Content-Type
来检测如何处理它。
This is actually how jQuery works. If you don't tell it what to do with the result, it uses the Content-Type
to detect what to do with it.