直接上代码:
var uri="domain/cmd.php"; var dataStr="name=张三&age=23"; var xhr = null; if (!window.ActiveXObject) { xhr= new XMLHttpRequest(); } else { xhr = new ActiveXObject("Microsoft.XMLHTTP");//IE适配 } xhr.open("POST", uri, true) xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(dataStr); xhr.onreadystatechange = function () { var data = xhr.responseText; console.log(data); }

微信扫码查看本文
发表评论