进行最基本的页面无刷新更新消息
//定义一个object
var checkExp=new Object();
//添加一个函数getXmlHttpRequestObject来判断是什么浏览器ie或firefox
checkExp.getXmlHttpRequestObject=function() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
document.getElementById('status_div').innerHTML = 'Status: Cound not create XmlHttpRequest Object.'+'Consider upgrading your browser.';
}
}
//1。定义getLocationsAndMap函数用get方法进行传递数据
checkExp.getLocationsAndMap=function() {
if (checkExp.receiveReq.readyState == 4 || checkExp.receiveReq.readyState == 0){
var url = "../map.html";
checkExp.receiveReq.open("GET",url, true);
//当通过服务器执行完毕,返回页面时跳转到另外一个函数getLocationsAndMapCallback_,数据将在这个函数中进行处理。
checkExp.receiveReq.onreadystatechange = checkExp.getLocationsAndMapCallback_;
checkExp.receiveReq.send(null);
}
}
//2。定义saveNewLocations 函数用post方法进行传递数据
checkExp.saveNewLocations=function() {
//利用json传递数据组(关于json,以后将进行讲解)
var json=cook.savedStocks.toJSONString();
var url = "../xmlrequest.html";
checkExp.receiveReq.open("POST", url);
checkExp.receiveReq.onreadystatechange = checkExp.handleStateChange_;
checkExp.receiveReq.send(json);
}
//定义一个object
var checkExp=new Object();
//添加一个函数getXmlHttpRequestObject来判断是什么浏览器ie或firefox
checkExp.getXmlHttpRequestObject=function() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
document.getElementById('status_div').innerHTML = 'Status: Cound not create XmlHttpRequest Object.'+'Consider upgrading your browser.';
}
}
//1。定义getLocationsAndMap函数用get方法进行传递数据
checkExp.getLocationsAndMap=function() {
if (checkExp.receiveReq.readyState == 4 || checkExp.receiveReq.readyState == 0){
var url = "../map.html";
checkExp.receiveReq.open("GET",url, true);
//当通过服务器执行完毕,返回页面时跳转到另外一个函数getLocationsAndMapCallback_,数据将在这个函数中进行处理。
checkExp.receiveReq.onreadystatechange = checkExp.getLocationsAndMapCallback_;
checkExp.receiveReq.send(null);
}
}
//2。定义saveNewLocations 函数用post方法进行传递数据
checkExp.saveNewLocations=function() {
//利用json传递数据组(关于json,以后将进行讲解)
var json=cook.savedStocks.toJSONString();
var url = "../xmlrequest.html";
checkExp.receiveReq.open("POST", url);
checkExp.receiveReq.onreadystatechange = checkExp.handleStateChange_;
checkExp.receiveReq.send(json);
}