Jump to content

Run a PHP Script at the end of a timer?


ronnie88

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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.