简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM