Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
159
rated 0 times [  161] [ 2]  / answers: 1 / hits: 26079  / 12 Years ago, thu, february 7, 2013, 12:00:00

I have a backbone app that has a ton of AJAX. (each page load results in 5-6 ajax calls) because I have many views and internal views within those views,



if I run Phantom.js, can I get the final html result?



Final result is what the user sees after all my ajax calls run.


More From » backbone.js

 Answers
25

PhamtonJs is a headless WebKit with JavaScript API. When crawling a page, PhatomJs will download all dependants requests such as images, js, css... It will also executes JS and ajax calls.
However the onLoaded callback is invoked when the page finishes the loading, not when there are no pending requests. So, you have to use a trick for this.



There are two way to solve the problem :




  • Wait until something effectively changed in you page (an element). The best example is waitFor.js

  • Wait a few seconds until no requests were received.


[#80375] Tuesday, February 5, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jonrened

Total Points: 627
Total Questions: 114
Total Answers: 99

Location: Zimbabwe
Member since Thu, Jul 21, 2022
2 Years ago
jonrened questions
Mon, Nov 2, 20, 00:00, 4 Years ago
Tue, May 19, 20, 00:00, 4 Years ago
Tue, Jan 21, 20, 00:00, 4 Years ago
Thu, Nov 7, 19, 00:00, 5 Years ago
;