how can i Parse an HTML response text of an XMLHttpRequest using js?
16:35 20 Jun 2019

here is the my code code :

const http = new XMLHttpRequest();
const url  = 'http://page/';

http.open('get', url, false);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

http.onreadystatechange = function ()
{
  if(http.readyState === 4)
  {
    if(http.status === 200 || http.status == 0)
    {
        let str = (http.responseText);
        results = document.getElementById('test').value;
        alert(results)
    }
  }
}

http.send();

how i can sort the str into html so i can get the value using document.getElementById ?

i have tried

var doc = document.implementation.createHTMLDocument("example");

doc.documentElement.innerHTML = http2.responseText; 

let test1 = doc.body.querySelector("#test").value;

it worked but it give me an empty value and when i looked at the response preview i found the value bar empty and the options are like in the factory default status . and when i looked in the html code of the page found the value in this line


javascript html http xmlhttprequest httpresponse