Click here to Skip to main content
15,894,825 members
Articles / Programming Languages / Javascript
Tip/Trick

Debugging AJAX using Javascript - Trick

Rate me:
Please Sign up or sign in to vote.
2.83/5 (4 votes)
11 Mar 2010CPOL 9.1K   1  
How to review dynamic HTML content from browser using JavaScript?These days everybody is using AJAX for web development. Sometimes we need to debug our AJAX code to review what actually get rendered in the browser. The problem is, if you view source code of the page, it will not display...

How to review dynamic HTML content from browser using JavaScript?



These days everybody is using AJAX for web development. Sometimes we need to debug our AJAX code to review what actually get rendered in the browser. The problem is, if you view source code of the page, it will not display Dynamic HTML content.

I have a quick trick to get Dynamic HTML content from a rendered HTML page, directly from the Browser. This is very useful when you need to trace an issue on live website.
JAVASCRIPT: alert(document.body.innerHTML);

All you need to do is to copy the code written above and paste in the URL box of Browser where you website page is opened and press Enter. It will show whole document content(dynamic) in an alert.

To get the Dynamic HTML content on the page itself, use this code:
JAVASCRIPT: document.write(document.body.innerHTML);

You can write your own JavaScript logic and run this way to get result according to your requirement.

All the Best!! :thumbsup:

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead AuthorGen Technologies
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --