Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. document.getElementById("area").innerHTML=xmlhttp.responseText;
  2. xmlhttp.open("GET","notfound.php?&mat=" + Math.random(),true);
  3. xmlhttp.send();
  4.  
  5. function sendByAJAX() {
  6. // get the user text and make it safe for HTTP transmission
  7. var userTxt = encodeURIComponent( document.getElementById('userTxt').value );
  8. // create the AJAX object
  9. var xmlhttp = new XMLHttpRequest();
  10. // assume successful response -- do NOT actually make this assumption in real code
  11. xmlhttp.onreadystatechange = function() {
  12. if (xmlhttp.readyState==4 && xmlhttp.status>=200 && xmlhttp.status<300) {
  13. // You'll probably want to do something more meaningful than an alert dialog
  14. alert('POST Reply returned: status=[' + xmlhttp.status +
  15. ' ' + xmlhttp.statusText + ']nnPage data:n' + xmlhttp.responseText);
  16. }
  17. }
  18. xmlhttp.open('POST', 'http://www.site.com/submit/path');
  19. // here we are overriding the default AJAX type,
  20. // which is UTF-8 -- this probably seems like a stupid thing to do
  21. xmlhttp.setRequestHeader('Content-type',
  22. 'application/x-www-form-urlencoded; charset=tis-620;');
  23. xmlhttp.setRequestHeader('User-agent' , 'Mozilla/4.0 (compatible) Naruki');
  24. xmlhttp.send(userTxt);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement