日期:2014-05-19 浏览次数:21017 次
function updatehits(id){
insid=id;
http= getXMLHTTPRequest();
var reurl=window.location.pathname;
string=reurl.substring(reurl.lastIndexOf('/')+1,reurl.length);
if(reurl.substring(0, 3)=="data"){
alert(string);
string =reurl.substring(0, 3);
}
var url="updatehits?id="+insid+"&o="+string+"";
if(http){ // 成功创建XMLHTTPRequest对象
http.open("POST",url,true); // 与服务端建立连接(请求方式post或get,地址,true表示异步)
http.onreadystatechange=callback; // 指定回调函数
http.send(null); // 发送请求
}
}
// 创建XMLHTTPRequest对象
function getXMLHTTPRequest(){
var xmlHttp;
if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest(); // 非IE浏览器,用xmlhttprequest对象创建
}else if(window.ActiveXObject){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); // IE浏览器用activexobject对象创建
}
return xmlHttp;
}
function callback(){
if(http.readyState==4){
if(http.status==200){
processResponse();
}
}
}
// 处理服务器端响应
function processResponse(){
var text=http.responseText;
var bool=text.substring(0,4);
var u=text.substring(4,text.length);
if(bool=="true"){
if(u=="institutionsResume.jsp"){
parent.window.location.href="jgnew.jsp?insid="+insid;
}
if(u=="res.jsp"){
parent.window.location.href="teacher.jsp?userid="+insid;
}
}else{
}
}