Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. function submitFormAjax() {
  2. let xmlhttp= window.XMLHttpRequest ?
  3. new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
  4.  
  5. xmlhttp.onreadystatechange = function() {
  6. if (this.readyState === 4 && this.status === 200)
  7. alert(this.responseText); // Here is the response
  8. }
  9.  
  10. let name = document.getElementById('name').innerHTML;
  11. let email = document.getElementById('email').innerHTML;
  12.  
  13. xmlhttp.open("POST","your_url.php",true);
  14. xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  15. xmlhttp.send("name=" + name + "&email=" + email);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement