Categories
Snippet Starters

AJAX

Nice example of a post request to another page and the returned data.

xhttp.onreadystatechange = function() 
{
  if (this.readyState == 4 && this.status == 200) 
  {
    alert(this.responseText);
  }
};
xhttp.open("POST", "doworkpage.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("parameter1=example&parameter2=moreexample");