Typically, when we want to retrieve data using AJAX
, we would use code like this:
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(xhr.readyState == 4 && xhr.status == 200){
elem.innerHTML = xhr.responseText;
}
}
But the question arises - can we obtain the result without setting it as elem.innerHTML
?
For example:
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(xhr.readyState == 4 && xhr.status == 200){
xhr.responseText;
}
}
The challenge I'm facing is that the output of my query is an HTML table generated by PHP and I prefer not to enclose it within additional elements.