Skip to content
Advertisement

JavaScript auto-incrementing a variable in jQuery and AJAX

I have JavaScript using jQuery and AJAX which creates a dynamic array, which has some values used for AJAX request as below;

JavaScript

The script is suppose to submit values in the array in array[i] for each AJAX request. I made a variable var i which auto increments.. But the script is not working.. The script works well if array[i] is replaced by array[0] or array[1] etc..

How can I solve the syntax error?

Advertisement

Answer

I fixed it… Thank you so much @Jed, @Pointy, @Crozin, and @Lord Vader for helping me to figure it out…. 🙂

I just take var i = 0; outside the loop…. above var array like;

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement