<分区>
如何在 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;
}