[web] $.post does not work in a loop?

Started by
1 comment, last by leiavoia 14 years, 1 month ago
I have to execute a php script on my server to tag a message as deleted but when I do more then one or two at a time it skips them. Here is an example:

function Delete(chk)
{
  for (i = 0; i < chk.length; i++)
  {
    if( chk.checked )
    {
      $.post( 'delete_message.php', { message: ID_Array } );
    }
  }
  window.location.reload()
}

Is there anyway to make the server process every request without skipping any?
Advertisement
You'll need to do only one post() function in the loop, passing a callback function which then does the next post() and passes a callback, etc.

What would be much cleaner and faster and easier, though, would just be to have delete_message.php support deleting multiple IDs at a go.
You'll also be happy to know that jquery 1.4+ has support for sending back arrays.

This topic is closed to new replies.

Advertisement