Answer the question
In order to leave comments, you need to log in
how to get html via ajax?
Hey!
I have a component, a separate folder. Inside, it is implemented on the MVC model, there is an html markup file for the component. But it is not possible to pull it into the view to render the component.
Ajax request is like this:
let xhr = new XMLHttpRequest();
xhr.open('GET', 'tmp/tmp.html', true);
xhr.onreadystatechange = () => {
if (xhr.readyState !== 4) {
return false;
}
if (xhr.status !== 200) {
console.log('...');
} else {
this.tmp = xhr.responseText;
}
};
xhr.send();
Answer the question
In order to leave comments, you need to log in
What exactly are you expecting? When data is received, the callback function is executed, the text of the response to your adjax request is passed to it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question