ronnie88 Posted July 23, 2008 Share Posted July 23, 2008 How would I run a php file at the end of a javascript timer...the timer I am using is below: <script type="text/javascript"> var alertTimerId = 0; function alertTimerClickHandler ( ) { if ( document.getElementById("alertTimerButton").value == "Click me and wait 30 min" ) { // Start the timer document.getElementById("alertTimerButton").value = "Click me to stop the timer!"; alertTimerId = setTimeout ( "showAlert()", 1800000 ); } else { document.getElementById("alertTimerButton").value = "Click me and wait!"; clearTimeout ( alertTimerId ); } } function showAlert ( ) { alert ( "Congratz Your Flight Has Finished! You Received $600!" ); document.getElementById("alertTimerButton").value = "Click me and wait!"; } </script> thank you in advance! Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 23, 2008 Author Share Posted July 23, 2008 okay not on another page but it would have to be a script in the same file so they can't go directly to the file and receive the cash... and sorry about the double post wouldn't let me edit the previous post. it would be a simple mysql query update. Thanks again Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted July 23, 2008 Share Posted July 23, 2008 is it that the page cant be reloaded or can be reloaded. if you can reload it just do a javascript redirect. if you can't use ajax Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 23, 2008 Author Share Posted July 23, 2008 well after this timer reaches zero i'd like it to go to the php file and update the mysql. I have no idea how to do this in Javascript, but javascript is the only countdown timer that I found that is proficient enough to do long periods Quote Link to comment Share on other sites More sharing options...
adam84 Posted July 23, 2008 Share Posted July 23, 2008 Like DJ Kat said, do you want to have the page to be refreshed or not? Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 23, 2008 Author Share Posted July 23, 2008 not to be refreshed thanks Quote Link to comment Share on other sites More sharing options...
adam84 Posted July 23, 2008 Share Posted July 23, 2008 Then once your timer expires, call your ajax request function (from Javascript) with the PHP script that you want to run. Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 23, 2008 Author Share Posted July 23, 2008 I have no idea on how to do that, sorry im a noob. I've searched on google and the forums... but still don't know how to incorporate into this script.. Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted July 23, 2008 Share Posted July 23, 2008 well if it is that you want to do the update without the page reloading you should read up on some ajax tutorials. try out some stuff and see what it does. the easiest way is to use javascript frameworks such as jquery prototype or dojo etc. but the basics described here where I originally learned it from 2 years ago would work. http://www.w3schools.com/Ajax/Default.Asp 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.