[英]Repeated execution after the function complete
It is essential that in the cycle of repeated request to file test.php carried out after the current response is received 在收到当前响应后,在重复请求文件test.php的循环中至关重要
Groups = {
'1': 1214,
'2': 1215,
'3': 1217,
'4': 1225,
'5': 1294,
'6': 1247
}
$.each(Groups, function (index, value) {
$.get('test.php', {
'call': value
}, function (result) {
$('.console_wrapper').append(result + '<br />');
});
// if the result obtained is performed again
// next
});
Try 尝试
Object.size = function (obj) {
var size = 0,
key;
for (key in obj) {
if (obj.hasOwnProperty(key)) size++;
}
return size;
};
var Groups = {
'1': 1214,
'2': 1215,
'3': 1217,
'4': 1225,
'5': 1294,
'6': 1247
}
var max = Object.size(Groups); //get size/length of Groups
i = 1;
function get_value(val) {
$.get('test.php', {
'call': val
}, function (result) {
$('.console_wrapper').append(result + '<br />');
if (i < max) { //if i is less than max
get_value(Groups[++i]); //call function with new value from Group
}
});
}
get_value(Groups[i]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.