I am very new to javascript/jquery so bare with me. I am using this
loop code below with a populated array called "listarray":


        for(var i in listarray){
                var currententry = listarray[i];
                var finalurl="phpscript.php?entry="+currententry;
                jQuery.ajax({
                  url: finalurl,
                  success: function(serverreply){
                  alert(currententry);
                }
                });
        }

The alerts will always be the exact same: the last item in the array.
So if there are 10 items in the array, it will alert the last one...
10 times. I'm trying to work with each entry, but I think my code
might be mixed up.

The script is a very dumbed down version of what I'm working on, but
it's where I'm having my problem. I need to be able to see the ajax
reply, and depending upon what that reply is, do something with the
current array entry. If I alert() the serverreply instead... that
works fine and gives different responses each time... but when I alert
() the "currententry" it's the last item in the array every time.

However, this only happens inside of the jquery.ajax().  Any
suggestions? Thanks!

Reply via email to