我找到了这行代码。此 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/