Javascript Loop With Ajax Call
I've been struggling all afternoon to understand how to make this work, hopefully someone can help. I have a simple requirement to run through a list of checked check boxes, retrie
Solution 1:
Ajax calls are asynchronous, so when the success callback is invoked, tid
has the value of the last item of the $('input[type=checkbox]')
.
You could use a closure:
functionopentickedrows() {
$('input[type=checkbox]').each(function () {
if (this.checked) {
tid = $(this).attr('name').replace("t_", "");
(function(tid) {
$.ajax({
url: '/transfer_list_details_pull.php?id=' + tid,
type: 'GET',
success: function (data) {
$('#r' + tid).html(data);
$("#r" + tid).show();
$("#box" + tid).addClass("row-details-open");
}
});
})(tid)
}
});
}
Post a Comment for "Javascript Loop With Ajax Call"