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
https://forums.phpfreaks.com/topic/165946-alert-saves-teh-day-but-whywhy/
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; }
      }      
   }

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.