Jump to content

alert() saves teh day but WHY.....WHY????


aceband

Recommended Posts

I have a function called 'Tags' That can Add/Delete/select from a database. When i remove a row from the database i run the function twice. The first time to delete the row then immediately after to refresh the data fetched from the database. The problem is that it doesn't always refresh with the new data UNLESS i have an alert in there:  For example:

function removeTag(key){
Tags('DeleteTag', key); //remove a row from the data
alert('slow down the proccess');
Tags('tagURLS',''); //refresh content of div with new data
}

 

With the alert in there between the two Ajax calls the refresh is fine. It's as if the pause between them gives it time to think (machine's don't think though :S). Anyhow is there a way i can do this WITHOUT the alert - it would be very annoying for users to have to keep closing an alert box!

 

Thanks for any help you can give and if i haven't explained clearly ill try to re phrase it :D

 

Chris

Link to comment
Share on other sites

you could create a sleep function ie

function sleep(naptime){
      naptime = naptime * 1000;
      var sleeping = true;
      var now = new Date();
      var alarm;
      var startingMSeconds = now.getTime();
      while(sleeping){
         alarm = new Date();
         alarmMSeconds = alarm.getTime();
         if(alarmMSeconds - startingMSeconds > naptime){ sleeping = false; }
      }      
   }

 

Link to comment
Share on other sites

Thanks for the quick reply :) that sounds like a much better idea than the alert(). Ill use that for now but i still can't get my head around why it would need that pause. Is it because i use the same 'xmlhttp' for both calls - could that cause this problem? I may try it with two separate ones and see if it helps.

 

Thanks

Chris

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.