0

I'm building a homepage where after the user have filled a form I need to run a rather long PHP script (populating my database). Therefor I'm trying to make a loading page to be displayed while the script is running and once it's done redirect to some other page.

I'm currently doing:

In form.php

<form method="post" action="load.php">
....
</form>

load.php have the loading page:

<?php
ob_start();
?>
<!DOCTYPE HTML>
<html>
...loading page here...
</html>
<?
ob_end_flush();
include 'add.php';
?>

Here i hope to show the page with ob_start and ob_end_flush, and the begin the script.

at the end of add.php I do

header('Location: redirect_to_here.php');
2
  • What about using AJAX? Commented Oct 28, 2015 at 10:20
  • tried but nut sure for to implement it properly Commented Oct 28, 2015 at 10:22

1 Answer 1

1
jQuery.post({
         url:    'http://example.com/save.php',
         data: { 'name':'name'
              },
      beforeSend:function(){
         $(".loading_msg").show();
    },
         success: function(result) {
         $(".loading_msg").hide();
                      if(result.isOk == false)
                          alert(result.message);
                  },
         async:   false
    }); 

make async false and before sending data show div and after success hide it

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.