Struggling to iterate through an ajax query and encountering a problem where the i value always defaults to 1. I'm not very well-versed in js so any suggestions on how to tackle this issue or possibly a better approach would be greatly appreciated. Thanks in advance!
$.each(Array(10), function(i) {
var clickedButton = $('#' + (++i));
$(clickedButton).click(function (){
$.ajax({
type: 'POST',
url: 'example.php',
data: {lightid: i},
success:function(result){}
});
});
});