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