In my javascript code I receive a value that tells me how many times I have to execute a piece of code but it executes just on time.
For example:
var qtt = 3;
for (var i = 1; i <= qtt; i++) {
console.log(i);
$.get( "/set-serie", function(seriedata)
{
console.log('test ' + i);
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
The result is:
1
2
3
test 4
So, this just execute the code one time instead 3. And I don't understand why it put 4 at the end.