<script type="text/javascript">
function myAjax(type,url,data,con,callBack){//type:请求方式 url:请求地址 data:请求的参数 con:是否异步 false代表同步 true代表异步,callBack回调函数
var xmlHttp = new XMLHttpRequest();
if(!con){
if(xmlHttp.onreadyState == 4){
var responseTest = xmlHttp.responseTest();
callBack(responseTest);
}
}
xmlHttp.open("POST","HELLO.jsp",true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");//如果是post就需要自定义请求头
xmlHttp.send(data);//JSON格式 {"name":"hehe"}
}
</script>
function myAjax(type,url,data,con,callBack){//type:请求方式 url:请求地址 data:请求的参数 con:是否异步 false代表同步 true代表异步,callBack回调函数
var xmlHttp = new XMLHttpRequest();
if(!con){
if(xmlHttp.onreadyState == 4){
var responseTest = xmlHttp.responseTest();
callBack(responseTest);
}
}
xmlHttp.open("POST","HELLO.jsp",true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");//如果是post就需要自定义请求头
xmlHttp.send(data);//JSON格式 {"name":"hehe"}
}
</script>