Download a new page using ajax

I am new to ajax and I wanted to know if we can load a full new page, not just a part of it with ajax. Please give a small example script to understand if possible. Here I am trying to display only one URL for the user when I switch from one page to another when he clicks on any of the links on the page.

+3
source share
5 answers

Of course, you can request a new page and load it through body.innerHTML = ajax.responseText;

I would strongly recommend against this, although for the reasons outlined in this post: Why not just use ajax for Page Requests to load page content?

, AJAX , -. .

AJAX . AJAX. .

AJAX: > 50% , , AJAX.

, , . Theres , , . , .

edit: document.write(ajax.responseText), , CSS .. .

+11

AJAX, JS:

window.location.replace('<URL of the new page>');

<a href="<URL of the new page>">...</a>.
+1

AJAX, URL-, . , , ( HTML), DOM. , , , , .

0

, , URL- , AJAX . IFRAME?

0

, , , "" . , ( - ) ( - ). , , . , , . , .

When the page receives a response, you can simply look at the first part of the response text and determine if it had a server-specified keyword, which means that it is a new page. Remove the keyword from the text and execute document.write (ajax.responseText); as described earlier. Otherwise, paste the response text into your divboxBoxBox and ask the user to resubmit.

0
source

Source: https://habr.com/ru/post/1724753/


All Articles