After an XHR request, the server response appears in the view source

I have a website where navigation is done using ajax, without reloading the page. Page loaded from the server using XMLHttpRequest, the server gives response in json format, the script pulls the html and writes the document.

So, if after was already committed at least one such query to open in the browser viewing the page's source code — there is code on the page is that the server I just gave json.

This is normal behavior? And is there a way to make there was just the page code, not the text of the last response from the server?
October 8th 19 at 01:26
4 answers
October 8th 19 at 01:28
As it is not entirely clear what's going on. You can even code to show?
Can you show a concrete example. Try for example here: (this is the site where the problem, do not consider for advertising). Open the source code (there will be a normal HTML). Close the source code and an open tab with the site click "Register". When the page loads, open the code view again. There is not html (as it should be), and json, which just came from the server. This behavior at least in Firefox, Chrome and Opera. - Tressa.Kautzer commented on October 8th 19 at 01:31
October 8th 19 at 01:30
Most likely you're not the source of the page and the source code of the selected fragment (e.g., use the context menu item "Firefox") that dynamically generated based on the current state of the DOM tree.
No, I open the code page it is in all browsers (a comment above already written in detail). - Tressa.Kautzer commented on October 8th 19 at 01:33
Please provide a minimal working example that demonstrates the situation you described. - Tressa.Kautzer commented on October 8th 19 at 01:36
Although see above. - Dariu commented on October 8th 19 at 01:39
And yet show minimal example.

P. S. Send the user to a page about the deprecated browser is only based on JavaScript disabled ("in the garden — elder, therefore, in Kiev — the uncle") — it's hard. - Dariu commented on October 8th 19 at 01:42
October 8th 19 at 01:32
And asynchronous requests are used to implement navigation? In other words, you use history.pushState?
Yes, I am. - Tressa.Kautzer commented on October 8th 19 at 01:35
October 8th 19 at 01:34
The browser behaves correctly in Your case. Try to do not GET /register/, and add any parameter, e.g. GET /register/?xhr, the Location to write /register/. Or try setting xhr to convey in the POST, but I'm not sure that would work.

Find more questions by tags JavaScriptHTMLWeb DevelopmentBrowsers