web 2.0

Debugging AJAX using Javascript - Trick

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!!