I am making an Ajax request query to get variables containing HTML code within a php file. I am currently using this method to display the content retrieved from the Ajax request:
document.getElementById('my_div').innerHTML = request.responseText;
However, when I view page source (Chrome) to see the HTML code on the page, the HTML retrieved from the Ajax response is not shown, but the effect of that HTML code is visible on the page.
Anyone know how to make the Ajax response visible as HTML so that it is visible on view page source?
View source will only show the html of the document when the page was loaded. Any dom manipulation done after that will not be visible in the view source.
You can see it in elements tab in the chrome console (f12) though.
Page source is the source as at when the page was loaded. You cannot get AJAX content to display here.
You can inspect the markup using the Webkit Inspector (Right-Click -> Inspect Element) on Chrome/Safari or Firebug on Firefox or use a debugging proxy such as Charles to watch the data sent/received (including any request data and the response HTML)
You can use your browser development tools to monitor network activity. This usually allows you to see the requests and responses your browser has issued for your current web page, including AJAX calls.