gpt4 book ai didi

JavaScript 将函数参数与返回值一起传递出去

转载 作者:行者123 更新时间:2023-11-30 10:01:36 25 4
gpt4 key购买 nike

<分区>

如何在 Java Script 中传递 ajax get 的函数参数以及返回值?

在下面的示例中,我想传入 GetServer 函数参数 id 的值,并使其可供函数 returnValue 访问

function getServerList(id) {
$.ajax({
type: "GET",
url: "/BackEndFunction/" + id,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: returnValue
});
}

function returnValue(Data) {
var _size = 0;
var id= id // passed from getserverlist
for (var i = 0; i< Data.length; i++) {
_size += Data[i]._size;
}
data_dictionary[id] = _size;
}

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