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;
};
};
};