52,797
社区成员
发帖
与我相关
我的任务
分享
function GetXmlHttpObject(){
var xmlHttp = null;
try{
xmlHttp = new XMLHttpRequest();
}catch(e){
try{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
function showMsg(title,pid,_marker){
xmlHttp = GetXmlHttpObject();
if(xmlHttp == null){
alert ("you browser don't support the ajax");
return;
}
var url = "http://localHost:8080/pm/pstatus_getStatus.action"
xmlHttp.onreadystatechange = stateChanged(title,pid,_marker);
xmlHttp.open("GET", url, true);
xmlHttp.send();
alert("ok");
}
function stateChanged(title,pid,_marker){
alert(xmlHttp.readyState);
if(xmlHttp.readyState==4){
var json = xmlHttp.responseText;
alert(json);
var _iw = createInfoWindow(json);
_marker.openInfoWindow(_iw);
_iw.addEventListener("open",function(){
_marker.getLabel().hide();
})
_iw.addEventListener("close",function(){
_marker.getLabel().show();
})
_marker.getLabel().addEventListener("click",function(){
_marker.openInfoWindow(_iw);
})
}
alert(xmlHttp.readyState);
}
xmlHttp.onreadystatechange =function(){ stateChanged(title,pid,_marker);};/////这样。。
this.getResponse().getWriter().write(
"{title:\"国家大剧院\",name:\"国家大剧院\",use:12,free:2}");
public String getStatus() {
this.getResponse().setContentType("text/html;charset=utf-8");
try {
this.getResponse().getWriter().write(
"{title:国家大剧院,name:国家大剧院,use:12,free:2}");
} catch (IOException e) {
e.printStackTrace();
}
return null;
}