Answer the question
In order to leave comments, you need to log in
Do-it-yourself Ajax menu?
Hello.
For the first time I am making a site on ajax, I wrote a script and I wanted to ask a couple of questions.
function load(url){
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = ()=>{
if (xhr.readyState == XMLHttpRequest.DONE){
if (xhr.status == 200) {
document.body.innerHTML = xhr.responseText;
history.pushState('', '', url);
}
else if (xhr.status === 400) {
alert('There was an error 400');
}
}
};
xhr.open('GET', url, true);
xhr.send();
}
Answer the question
In order to leave comments, you need to log in
in short lol I sketched a fiddle, but it works in an iframe, and there is no access to pushState
exactly this site on vue.js, there is already a built-in so-called "router" that does exactly what is needed, here you can briefly see
https://router .vuejs.org/ru/
here is the fiddle, only it doesn't work :D
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question