function chkdiv(divid){ var chkid=document.getElementById(divid); if(chkid != null){return true; } else {return false; } } if (chkdiv('support')) {document.getElementById('support').innerHTML='
';} function uservote(str) { //创建XMLHttpRequest对象 var xmlhttp; try{ xmlhttp=new XMLHttpRequest(); }catch(e){ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } //创建请求结果处理程序 xmlhttp.onreadystatechange=function(){ if (4==xmlhttp.readyState){ if (200==xmlhttp.status){ var content=xmlhttp.responseText; //alert('投票成功!感谢您的支持!'); switch(content){ case "0": alert("您没有登陆,请先登陆"); break; case "1": alert("请先下载该资源在投票"); break; case "2": alert("投票成功!感谢您的支持!"); var support = document.getElementById('show_1').innerHTML; support++ ; document.getElementById('show_1').innerHTML=support; break; case "3": alert("投票成功!感谢您的支持!"); var support = document.getElementById('show_0').innerHTML; support++ ; document.getElementById('show_0').innerHTML=support; break; case "4": alert("已经参与过了"); break; case "5": alert("网络故障,请稍后重试1。"); break; } //document.getElementById('show_'+str).innerHTML=content; }else{ alert('网络故障,请稍后重试。'); } } } //打开连接,true表示异步提交 xmlhttp.open("post", "/Down/include/UserVote.asp", true); //当方法为post时需要如下设置http头 xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded'); //发送数据 xmlhttp.send("ID="+escape(4231380)+"&action="+escape(str)); }