How to detect if a webpage is waiting on a php script

160 Views Asked by At

In this web project I'm working on, users have the ability to upload images and files to the page using a simple input[type=file]. But this functionality is in a php script elsewhere, so we have put an iframe in our webpage that links to the php script. Now when I upload a file, I have a longish wait time while the file loads, and I see "waiting on localhost" (using MAMP) in the bottom left of my browser. Is there a way I can detect that the webpage is waiting for the php script to finish executing so I can show a loading animation and disable a submit button? I can't use jQuery.

1

There are 1 best solutions below

0
On

The iframe has its own load event which you should be able to listen for, assuming that both pages are on the same domain.

If that doesn't work, you can look for the domcontentloaded event, which is detailed quite heavily over in this question:

Detect DOMContentLoaded in iframe