sdifjow
var method = "post"; var xhr = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); xhr.onreadystatechange = function(){ if(xhr.readyState === 4 && xhr.status === 200){ alert(xhr.responseText); } }; if(method === "post"){ xhr.open("post","t.php"); xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xhr.send("name=john"); }else{ xhr.open("get","t.php"); xhr.send(); }