XMLHttpRequest 对象
一般都是忽略ie6以下的低版本浏览器,如果做到兼容性如下:
var request; if(window.XMLHttpRequest){ request= new XMLHttpRequest();//ie7+,ff,chrome,opera,safari. }else{ request = new ActiveXObject("Microsoft.XMLHTTP");//ie5 6}
语法:
open(method,url,async); //method请求方式不区分大小写,url相对绝对地址都可,async默认true异步,false同步 send(string);
发送请求:
request.open("get","get.php",true); request.send(); request.open("post","create.php",true); //setRequestHeader 设置头部信息,必须要写在 open()和sent()的中间,否则抛出异常 request.setRequestHeader("Content-type","application/x-www-form-urlencoded"); request.send("name=wjy&sex=female");
相关推荐
jiaguoquan00 2020-07-07
zhaolisha 2020-06-12
坚持着执着 2020-06-05
knightwatch 2020-04-25
zhaolisha 2020-01-11
zhaolisha 2019-12-29
wanghongsha 2019-12-06
小小大人物 2014-01-19
loopstang 2014-01-11
roodyszz0 2019-11-17
81493369 2019-11-04
Liuzhiqianblog 2019-11-03
用不完的好奇心 2019-10-26
89241846 2019-09-12
青菜萝卜白菜 2019-07-03
荒唌Blog 2017-12-18
无材可去补苍天 2019-06-12
HAcSeeking 2018-11-05