How to detect when a website which uses AJAX is completely loaded?

有些话、适合烂在心里 提交于 2019-12-11 04:38:46

问题


For a website, which doesn't use AJAX I'm using OnDocumentComplete event to know when the page loading is complete.

My question is, how can I detect when website, which uses AJAX requests is ready (e.g. when a website which is fetching some search results by using AJAX finished its work) ?


回答1:


Ok here is a trick i developed my self.

1-in your html page make a div and set its text to "false".

2-in you server side put a javascript at the end of your returning code. for example your site returns following text upon an ajax call.

a b c d e

so after this text put a javascript code that will change the text of div from "false" to "true"

so what will happen is that once you receive all the data from ajax call you will also receive the javascript code and that code will run and set the value of div.

so in your page once all data is received you will see the indicator div. and you will know that you have received all data. you can also run functions in similar way upon completion of data.



来源:https://stackoverflow.com/questions/15157002/how-to-detect-when-a-website-which-uses-ajax-is-completely-loaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!