The following code is launched from www.example.com and gets the full html source code of www.example.com/example.html and alerts it.
function process(){
url = "http://www.example.com/example.html"
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4){
alert(xhr.responseText)
}
}
xhr.send();
}
process();
Now what i want to do is get the email from the html source code which is like this:
<input type="hidden" id="email2" name="email2" value="example@example.com" />
Usually if i were on the page itself i'd just do a simple:
document.getElementById('email2').value
But in this case how do i simply parse the email into a variable from the variable containing all that html source code which is:xhr.responseText
?