Loading Page.....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sjwdavies
Forum Commoner
Posts: 25
Joined: Mon Nov 17, 2008 10:18 am

Loading Page.....

Post by Sjwdavies »

Hi guys, i'm wondering if you can help me out with an idea i've got.

I'm building an insurance quote popup window, and some tasks can take a little time to process so i'm thinking of building a 'Loading...' page that'll appear in between each screen.

So when a customer for example clicks 'Log In', the screen will go white with a loading image in the middle, then Ajax or something similar calls a PHP script (while the user is looking at a loading icon), and once the php has been executed redirect the browser.

Do you think this is a good way of doing it? Does anyone have any example URL's? I've tried looking but haven't found any that do what I need.
godwinsam
Forum Newbie
Posts: 9
Joined: Wed Sep 16, 2009 11:01 pm

Re: Loading Page.....

Post by godwinsam »

Hello,

Please find the following link,
http://thybag.co.uk/index.php?p=Tutorials&ind=44
Here we have the coding and steps to Ajax page Loading.
Sjwdavies
Forum Commoner
Posts: 25
Joined: Mon Nov 17, 2008 10:18 am

Re: Loading Page.....

Post by Sjwdavies »

Thanks but that's not really what i'm looking for...

I've come up with the following script that does exactly what i'm looking for:

Code: Select all

<?php
// Construct the data as a string
foreach($_POST as $key => $value) {
    $variables .= $key . "=" . $value . "&";    
}
$variables = substr($variables, 0, strlen($variables)-1);
//echo $variables; die();
?>
<html>
<head>
<title>Processing</title>
    <script type="text/javascript" src="/jscript/jquery-1.3.2.js"></script>
    <!-- http://docs.jquery.com/Ajax/load -->
    <script type="text/javascript"> 
        $(document).ready(function(){       
             $.ajax({
               type: "POST",
               url: "code/<?php echo $_GET['action']; ?>.php",
               data: "<?php echo $variables; ?>",
               success: function(msg){
                    window.location=msg;
                    //widnow.alert( "Data Saved: " +  );
               }
             });
        }); 
    </script>    
</head>
<body>
    <div style='width:100px; height:100px; margin:230px auto 0px auto;'>
        <img src="images/ajax-loader-blue.gif" border="0">
    </div>
</body>
</html>
Post it here for your comments or as help to others
Post Reply