简体   繁体   中英

Run a PHP function on document ready?

Is there anyway for me to run a certain php function when the document loads completely? I am trying to run a function which will mark a notification as read only when the document has been loaded completely. What can I do?

You can detect the "document-ready" event with a Javascript script and when that is triggered, perform an AJAX request to a PHP page that will run the script you need.

With jQuery it gets as simple as using ready() and ajax() .

是的你可以在文件准备好的时候对那个php文件进行ajax调用。

您必须为此使用AJAX,因为php是在服务器端完成的,所以AJAX是唯一的方法:)

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