I’m having a loop problem. It doesn’t increase the ‘i’ value from 0. Can you help me?
Here’s my code:
var users = ["a", "b", "c"];
if (users.length > 0) {
$(".ajax").live("submit", function(){
for (var i=0; i < users.length; i++) {
console.log(i);
var forma = $(this);
$("input[name=_session]", forma).val(users[i]);
ajaxy(forma, function(data){
console.log(data.status);
});
return false;
}
});
} else...
You return false after the first iteration of the loop. I think you need to move the
return false;line out of the loop block.Properly indenting your code will make errors like this obvious: