/** * Created by Administrator on 2016/12/19. */ //type:类型:GET OR POST //address:路径; 返回值为获取的json对象 function getJson(type,address,Good){ var http; if(window.XMLHttpRequest){ http = new XMLHttpRequest(); }else{ http = new ActiveXObject("Microsoft.XMLHTTP"); } //处理数据 http.onreadystatechange = function (){ if(http.readyState == 4 && http.status == 200){ var JsonStr = http.responseText; var json = JSON.parse(JsonStr); //处理数据 Good(json); } }; //发送请求 http.open(type,address,true); http.setRequestHeader("content-type","application/x-www-form-urlencoded"); http.send(); }
ajax封装
最新推荐文章于 2023-09-20 10:27:08 发布