var xhr = new XMLHttpRequest(); //设置请求基本信息,并加上请求头 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xhr.open('post', 'test.php