ajax异步请求post方式
来源:动视网
责编:小采
时间:2020-11-27 20:12:59
ajax异步请求post方式
ajax异步请求post方式:<script> //创建浏览器对象 function createXhr(){ //判定浏览器类型处理第一种方法 /* var xhr; var str=window.navigator.userAgent; if(str.indexOf('MSIE')>0){ xhr=new ActiveXObje
导读ajax异步请求post方式:<script> //创建浏览器对象 function createXhr(){ //判定浏览器类型处理第一种方法 /* var xhr; var str=window.navigator.userAgent; if(str.indexOf('MSIE')>0){ xhr=new ActiveXObje

<script>
//创建浏览器对象
function createXhr(){
//判定浏览器类型处理第一种方法
/* var xhr;
var str=window.navigator.userAgent;
if(str.indexOf('MSIE')>0){
xhr=new ActiveXObject('Microsoft.XMLHTTP');
}else{
xhr=new XMLHttpRequest();
}
return xhr;
*/
try{
return new ActiveXObject('Microsoft.XMLHTTP');
}catch(e){
}
try{
return new XMLHttpRequest();
}catch(e){
}
};
//ajax Post请求
var data="username=zs&&password=123456";
var xhr=createXhr();
xhr.onreadystatechange=function(){
if(xhr.readyState==4&&xhr.status==200){
};
}
xhr.open("post","/ajaxPost1");
xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded')
xhr.send(data);
</script>
ajax异步请求post方式
ajax异步请求post方式:<script> //创建浏览器对象 function createXhr(){ //判定浏览器类型处理第一种方法 /* var xhr; var str=window.navigator.userAgent; if(str.indexOf('MSIE')>0){ xhr=new ActiveXObje