0

I have a PHP script (download.php) that receives Form Post data from the index.php page.

The processing takes a while to submit the form thus making the browser loading (the spinning wheel) for quite some long time.

Can I force the browser not to show the gray loading wheel until the form is submitted and the Post page (download.php) is done and ready to display?

For example like Youtube is doing now, they show a progress bar on top but the browser is not loading at all.

  • You should use an Ajax request to prevent the browser from loading. – scorgn Jan 14 '17 at 02:02
  • But using Ajax doesn't redirect to the page it posted/submitted to, it only sends the request using XHR and waits for a response (usually JSON) from download.php – user3137873 Jan 14 '17 at 02:04
  • I believe the only way to do this is with AJAX and a function on success. You could have the download.php page set `$_SESSION` variables, and then on success redirect the user to download.php and have it then access the `$_SESSION` variables. – scorgn Jan 14 '17 at 02:13
  • It's possible I don't understand what you're trying to achieve, but if it's server side code that is taking a long time (such as preparing a download) then I would do this. If it's simply a lot of client-side information that the page needs to load, then I do not know of a solution. – scorgn Jan 14 '17 at 02:19
  • Is there any way to prevent the browser from showing the loading spinning wheel when going from a page to another? (just like what Youtube is doing). If so, I can then show a progress bar/loading wheel of my own and it would redirect like normal... – user3137873 Jan 14 '17 at 02:22
  • Youtube doesn't actually redirect, I took they use `history.pushState();` to change the URL. As far as I know it is not possible to directly prevent the browser from showing the loading wheel when going from one page to another. – scorgn Jan 14 '17 at 02:47
  • http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously – Cesar Bielich Jan 14 '17 at 04:47

2 Answers2

0

To achieve an effect similar to youtube you would need to use AJAX in conjunction with the history.pushState();.

Youtube has released a framework called spfjs for achieving the same effect that their own website has. Take a look at https://youtube.github.io/spfjs/.

scorgn
  • 3,439
  • 2
  • 20
  • 23
0

If you click submit button and move to download.php, the web browzer will definitely show a loading tab. To avoid this, AJAX can be used.

Once the form data are submitted by means of AJAX, you can also receive back the download.php page contents ready to be displayed using the same AjAX response. Then hide the contents of index.php and place the received html instead. I hope it will work, for I am using this method. Thank you.

bonyem
  • 1,148
  • 11
  • 20
  • I tested this AJAX method, but what I want to achieve is a normal redirection to "download.php" after form submission, but instead of the browser showing the loading wheel I want to show my own progress bar and redirect once the page is ready... – user3137873 Jan 14 '17 at 17:17