aceband Posted July 14, 2009 Share Posted July 14, 2009 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 Chris Quote Link to comment Share on other sites More sharing options...
MadTechie Posted July 14, 2009 Share Posted July 14, 2009 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; } } } Quote Link to comment Share on other sites More sharing options...
aceband Posted July 14, 2009 Author Share Posted July 14, 2009 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 Quote Link to comment Share on other sites More sharing options...
MadTechie Posted July 14, 2009 Share Posted July 14, 2009 Using the same xmlhttp, for both could be the problem, try making it a global array, and use a different element for each. as the first call will not be returned as its overwritten with the second call Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.