var getjson = function(){
var xhr = new XMLHttpRequest();
xhr.open("POST","ajax.php",true);
//post方法需要设置header头"setRequestHeader"
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xhr.send("id=2046");
xhr.onreadystatechange = function(){
if(xhr.readyState==4&&xhr.status==200){
var obj = JSON.parse(xhr.responseText);
document.querySelector("main").innerHTML = obj.classify;
};
};
};
转载于:https://my.oschina.net/u/1041665/blog/978874
最后
以上就是眼睛大小海豚最近收集整理的关于XMLHttpRequest对象使用“POST”方法,需要设置“setRequestHeader”的全部内容,更多相关XMLHttpRequest对象使用“POST”方法内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复