最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ajax php仿网易文章评论顶一下效果
时间:2022-06-24 18:22:04 编辑:袖梨 来源:一聚教程网
ajax php教程仿网易文章评论顶一下效果
[5]
js ajax
function setcookie(c_name,value,expiredays){ //设置cookie
var exdate=new date();
exdate.setdate(exdate.getdate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.togmtstring());
}function createxmlhttprequest(){ //创建xmlhttprequest对象
if(window.activexobject){ //ie
try {
return new activexobject("microsoft.xmlhttp");
} catch(e){
return;
}
}else if(window.xmlhttprequest){ //mozilla,firefox
try {
return new xmlhttprequest();
} catch(e){
return;
}
}
}function get_top_num(id){ //主调函数
var get_top_cookie=getcookie('get_top_'+id+'_cookie');
if(get_top_cookie!=null && get_top_cookie!=""){
alert('此条评论你已经支持过了');
}
else{
var xmlhttp=createxmlhttprequest();
var url = "action.php?action=top_num&id="+id;
if (id==""){
return false ;
}
if (xmlhttp){
callback = getreadystatehandler(xmlhttp,id);
xmlhttp.onreadystatechange = callback;
xmlhttp.open("get", url,true);
xmlhttp.send(null);
}
setcookie('get_top_'+id+'_cookie','istop',1);
}
}function getreadystatehandler(xmlhttp,id){ //服务器返回后处理函数
var top_num = document.getelementbyid("top_num_"+id).innerhtml;
return function (){
if(xmlhttp.readystate == 4){
if(xmlhttp.status == 200){
if (xmlhttp.responsetext==1){
document.getelementbyid("top_num_"+id).innerhtml=number(top_num)+1;
}
}
}
}
}//-->
相关文章
- 王者荣耀西施去衣无遮挡高清图分享-王者荣耀西施去衣无遮挡高清图大全 01-30
- 樱花漫画在线阅读全集免费-海量日漫国漫资源一键畅看无广告 01-30
- 大话西游云游戏极速入口-大话西游云端畅玩免下载在线直达 01-30
- 美赛官网登录入口-美国大学生数模竞赛官方访问 01-30
- 数学建模美赛时间查询-美国大学生数学竞赛官网入口 01-30
- fifa18网页版直达-fifa18试玩中文版一键入口 01-30