gpt4 book ai didi

javascript - jQuery 中的 AJAX 调用,什么定义了 "json"作为参数?

转载 作者:行者123 更新时间:2023-11-28 13:35:24 27 4
gpt4 key购买 nike

我找到了这行代码。此 AJAX 调用的最后一个参数是字符串“json”。

它代表什么?

$.get(theUrl, function(e) {
make(e);
}, "json")

最佳答案

这意味着ajax将返回数据类型 json

数据类型:(例如:xml、json、脚本或 html)

The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string). The available types (and the result passed as the first argument to your success callback).

<小时/>

"json": Evaluates the response as JSON and returns a JavaScript object. 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. (See json.org for more information on proper JSON formatting.)

关于javascript - jQuery 中的 AJAX 调用,什么定义了 "json"作为参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21812491/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com