Is there anyway for me to run a certain php function when the document loads pletely? I am trying to run a function which will mark a notification as read only when the document has been loaded pletely. What can I do?
Is there anyway for me to run a certain php function when the document loads pletely? I am trying to run a function which will mark a notification as read only when the document has been loaded pletely. What can I do?
Share Improve this question asked Oct 6, 2013 at 12:51 christianleroychristianleroy 1,1045 gold badges25 silver badges39 bronze badges 1-
Reconsider your logic or just use
ajax
or load anIMG
inJS
onLoad
. PHP is long finished building your page's HTML when your document ready gets triggered. You need to callback to achieve the result you seek. – CodeAngry Commented Oct 6, 2013 at 12:56
3 Answers
Reset to default 7You 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().
yes you can do an ajax call to that php file on document ready.
You must use AJAX for this, php is done server side so AJAX is the only way :)