gpt4 book ai didi

javascript - ajax成功函数参数data和response有什么区别?

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

响应和数据都给我带来了正确的响应,但它们之间有什么区别。

 $("button").click(function(){
$.get("demo_test.asp", function(data, status){ //if I put response instead of data is also working
alert("Data: " + data + "\nStatus: " + status);
});
});

但是,我想知道我什么时候应该去获取响应和数据。

最佳答案

这只是参数名称。你可以随意调用它。您可以将其命名为 foo,它的工作方式相同。

All arguments passed to the function are treated as the names of the identifiers of the parameters in the function to be created, in the order in which they are passed.

来自:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function

您还可以使用 arguments 对象来访问参数:arguments[0] 也可以起到同样的作用。

关于javascript - ajax成功函数参数data和response有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31388391/

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