[英]Is data a reserved variable in getJSON() callback function?
Here is the descrition of getJSON
in jquery
: 这是
jquery
对getJSON
的描述:
$(selector).getJSON(url,data,success(data,status,xhr))
Here success(data,status,xhr)
is a callback function when success. 这里
success(data,status,xhr)
是成功时的回调函数。 I often see the code below: 我经常看到下面的代码:
$(select(.getJSON('my/url', function(data) {....});
Here variable data
holds the data returned by the http
server. 这里,变量
data
保存由http
服务器返回的数据。 My question is that instead of using name data
here, can I use variable name like server_data
as below? 我的问题是,我可以在下面使用像
server_data
这样的变量名,而不是在这里使用名称data
吗?
$(select(.getJSON('my/url', function(server_data) {....});
It's a function argument name. 这是一个函数参数名称。 You can name it whatever you want, so long as it follows the valid javascript variable name format.
您可以根据需要命名,只要它遵循有效的javascript变量名称格式即可。
Ref: What characters are valid for JavaScript variable names? 参考: 哪些字符对JavaScript变量名称有效?
Edit: Also, easy enough to test without asking a question. 编辑:此外,足够容易进行测试,而无需提出问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.