Call PHP from Javascript :: Reload html when php is done processing

Discussion in 'JavaScript' started by robster, Jan 1, 2007.

  1. #1
    I have a php script that needs to be run, at a users request. I want the user to click a button(image) and at that point, the php script will run. When finished, the page will reload.

    I tried doing a "loading .... " page, which I redirected to the php script... but the script takes too long to load, and so the browser timed out.

    Does anyone know how to do this?

    Thanks
     
    robster, Jan 1, 2007 IP
  2. frankcow

    frankcow Well-Known Member

    Messages:
    4,859
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    180
    #2
    Use AJAX to load it in the background and do a callback when it's done
     
    frankcow, Jan 1, 2007 IP
  3. robster

    robster Peon

    Messages:
    94
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Do you know of a simple script that can accomplish this...

    I am not up to speed on ajax yet.
     
    robster, Jan 1, 2007 IP
  4. KalvinB

    KalvinB Peon

    Messages:
    2,787
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #4
    have the php script spit out a meta refresh tag when it's done. the browser will take care of the rest.
     
    KalvinB, Jan 5, 2007 IP
  5. jonnyfishman

    jonnyfishman Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Don't know f this is any help. If your after a really easy/lazy way to do it use the javascript: history function.
    I use it for an email form on my page, its not the prettiest way but it works without any problems as follows. In the middle of the php script add the end code tags and place javascript as below.


    
    mail( "someemail@mail.com", "Subject", "Name: $name\n \nMessage: $message\n \nFrom: $email", "From: $email" );
          ?> 
        <script language="Javascript">
        javascript: history.go(-1)
        alert ("Your message has been sent. Thanks for the interest.")
        </script> 
    <?
    
    Code (markup):
    Hope this helps :)
     
    jonnyfishman, Jan 6, 2007 IP