Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Viewing HTML response from Ajax call through Chrome Developer tools?

So in my javascript I'm making an ajax call to a service on my website. Whoops, something fails. No problem. Here's what I'd do in Firefox:

  1. Open the firebug console
  2. Find the failed Ajax call and click the + sign to see more info.
  3. The response tab has the raw HTML. Who wants to read all that? I click the HTML tab.
  4. Ah, the nicely formatted HTML returned by Django shows my divide by zero error.

Now here's what I currently do in Chrome:

  1. Ctrl+Shift+J to open the Developer Tools
  2. Go to Resources
  3. Scroll down to the Ajax call and click
  4. Once again, I see raw HTML. Still don't want to read all that, but since there isn't an HTML tab I copy and paste into a text editor.
  5. Save html file
  6. Open html file in browser so I can read the error HTML returned by Django

So on to the question. Is there anyway to view the HTML response from an Ajax call rendered in the browser without having to copy and paste the raw html to a text editor?

like image 979
Eric Palakovich Carr Avatar asked Jul 05 '10 17:07

Eric Palakovich Carr


People also ask

How do I view HTML responses in Chrome?

Right-click a page and select "Inspect Element". This displays the HTML code for the element you clicked.

How do I view responses in Chrome dev tools?

To view the request or response HTTP headers in Google Chrome, take the following steps : In Chrome, visit a URL, right click , select Inspect to open the developer tools. Select Network tab. Reload the page, select any HTTP request on the left panel, and the HTTP headers will be displayed on the right panel.


2 Answers

Nope, there is currently no way. When you goto Developer Tools > Resources > XHR Tab > And click on your resource (on the left), you see two tabs. The first one being Headers (which is raw) and Content which is raw as well.

like image 57
Mohamed Mansour Avatar answered Oct 15 '22 08:10

Mohamed Mansour


Just for your information, while Firebug Lite does not have a NET panel, it does have a XHR watcher feature with the same look and feel of Firebug. Of course, Firebug Lite is very limited compared to Chrome Developer Tools, but for some specific tasks like CSS editing or XHR inspection, Firebug Lite does the job very well.

The current stable version shows you the HTTP headers, GET and POST variables, and the response text. But the next version 1.3.1 (which will be released soon) includes the HTML viewer, XML viewer and the handy JSON viewer (for both request and response data).

This feature will be included in the next release 1.3.1b2 (probably the last beta version for the 1.3.1 version), but if you want to see it running right now you can use the developer channel.

like image 31
Pedro Simonetti Avatar answered Oct 15 '22 09:10

Pedro Simonetti