Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delay for Simple HTML DOM Class

I'm using the simple html dom class and have gotten it to work on basic pages and can view the information I want. However, when I attempt to use it on a page that reloads a div with ajax, I can't seem to get it to "wait" before reading the page.

I basically want it to load the page, then wait 2 seconds before reading the page content (so that the new div has time to load). Is this possible or am I trying to use the class incorrectly? I'm manually inputting the URL, so it's not a link issue.

Example Page: - You can see the load issue when you navigate through the pages.

Someone suggested curl and I tried that with the same results.

Thanks in advance.

like image 916
Michael Luyties Avatar asked Jan 16 '12 17:01

Michael Luyties


1 Answers

PHP runs on the server. JavaScript (e.g. AJAX) runs in the browser, after the PHP code on the server has finished producing the page. You can't make a PHP program, running on the server, wait for an event that happens later in the browser.

You'll need to either load the content for that div using PHP code, or replace the PHP DOM-parsing code with JavaScript code that does the work on the client.

like image 65
Wyzard Avatar answered Oct 14 '22 04:10

Wyzard