Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / Javascript

Debugging AJAX using Javascript - Trick

2.83/5 (4 votes)
11 Mar 2010CPOL 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)