I have a button in my html page and when i click on that following function is called:
$("#rlsLckButton").click(function () {
var userIds = '';
var messages = [];
for (i = 1; i < counter; i++) {
userIds = $('#textbox' + i).val();
if (userIds != " ") {
$.getJSON('execLock.action', {
RsUserIds: userIds
}, function (json) {
for (var i = 0; i < json.returnMessages.length; i++) {
messages.push(json.returnMessages[i]);
}
});
}
}
$("#TextBox").empty();
for (var i = 0; i < messages.length; i++) {
$("#TextBox").append('<p>messages[i]</p>');
}
});
So what is happening is it is calling $getJson function then its coming out of it and executing other code
$("#TextBox").empty();
for (var i = 0; i < messages.length; i++) {
$("#TextBox").append('<p>messages[i]</p>');
}
Then again its calling same getJSON function and this time its populating the values but not calling next followed code and coming out of the function. Not sure why its happening .Please suggest ! Help is appreciated.
' + message + '
' }).join('') $("#TextBox").append(html); }); } } });` – Arun P Johny Dec 12 '13 at 07:08