【发布时间】:2017-05-24 10:29:52
【问题描述】:
我尝试了不同的代码和设置,但仍然无法正常工作。我想将数组中的所有值添加到 jQuery 的 makeSpaceInactive 函数中。
$(document).ready(function() {
var myArray = [ 'AB', 'AC']
function makeSpaceInactive(spaceKey) {
jQuery.ajax({
contentType: 'application/json',
type: 'POST',
url: '/rpc/json-rpc/confluenceservice-v2/setSpaceStatus',
data: '["SPACEKEY", "ARCHIVED"]',
success: function(response) {
console.log(response);
}, error: function(response) {
console.log(response);
}
});
});
$.each(myArray, function (index, value) {
makeSpaceInactive(value);
});
})
myArray 中的值应该在 makeSpaceInactive 函数中与 SPACEKEY 所在的 data 函数循环。但我不知道如何用 myArray 值替换 SPACEKEY 数据?
【问题讨论】:
-
您想将整个数组传递给您的
makeSpaceInactive函数还是一次一个值? -
一次一个值!
标签: javascript jquery json ajax rpc