在线等待!!!!!! 一个页面打开30秒,数据库更新 ( 没有触发事件) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在window的load事件中触发window.onload = function () { var i = 0; if (i <= 30) { setTimeout(function () { i++; ajax("更新数据库") }, 1000); }};你的30秒事件是否执行,ajax是否请求正常,后台代码可有执行 ajax("更新数据库") 这里面怎么写?? 用AJAX异步请求数据库,1楼写的伪代码呢 没学ajax,代码贴出来。谢谢 急急! 第一步引用 jquery 包 1.2.6 以上版本 function AddContentSave() { var CContent = $("#txtContent").val(); if (CContent == null || CContent == "" || CContent.length <= 0) { alert("回复信息不能为空!"); return; } if (CContent.length > 1500) { alert("回复信息不能超过1500字!"); return; } $.ajax({ type: "post", url: "/Action/Ajax.aspx",///这里是处理页面 data: { action: "saveContentReply", ContentID: contentID, companyID: companyID, userID: userid, CContent: escape(CContent), SubID:SubID }, cache: false, success: PostCallBack, error: AjaxFailCallBack }); } //保存AJAX回调 function PostCallBack(data) { if (data == null || data.toString() == null || data.toString() == "" || data.toString().length <= 0) { alert("添加失败!"); return; } if ($("#contentreply").css("display") == "none") $("#contentreply").css("display", "block"); var content = data.toString().split("^!*@"); $("#replylist").prepend(content[0]); $("#txtContent").val(""); $("#replynumber").html(parseInt($("#replynumber").text()) + 1) $("#replynumber1").html(parseInt($("#replynumber1").text()) + 1) alert(content[1]); $("#fEmpty").text(""); } //Ajax发生错误时 function AjaxFailCallBack(XMLHttpRequest, textStatus, errorThrown) { alert("操作失败"); } //刷新页面 function RefreshUserContentReply() { $.ajax({ type: "post", url: "/Action/Ajax.aspx", data: { action: "getContentNewsReply", ContentID: contentID, companyID: companyID, userID: userid, ReplyID: ReplyID, SubID:SubID }, cache: false, success: PostRefrisehCallBack, error: AjaxRefrisehFailCallBack }); } function AjaxRefrisehFailCallBack(XMLHttpRequest, textStatus, errorThrown) { } //刷新页面回调 function PostRefrisehCallBack(data) { if (data == null || data.toString() == null || data.toString() == "" || data.toString().length <= 0) return; var content = data.toString().split("^!*@"); $("#replylist").prepend(content[0]); ReplyID = content[1]; $("#replynumber").html(parseInt($("#replynumber").text()) + parseInt(content[2])) $("#replynumber1").html(parseInt($("#replynumber1").text()) + parseInt(content[2])) } $(function() { setInterval(RefreshUserContentReply, 10000); });示例处理页接收参数的方法 ajax.aspxstring action = Request.Params["action"].ToString();话到这份上,你必须会了 求助,本人js新手,现制作一个左侧3级导航,从数据库里提数据,求指导 window.open 参数,location在ff下不起作用,请教了!! EasyUI [严重求助]ie浏览器问题. 如何通过js控制上下箭头(如:up,down)的使用? return 语句在函数之外?求解 正则怎么替换好 写了一个JS函数,可惜不明原因地失效 100分给beyond_xiruo(CorruptionException) 如何使IE窗口一打開就最大化?(點擊右上角最大化按鈕之后的效果) 为什么提交会弹出三个窗口 正则表达式的问题?匹配很长的一串字符!
window.onload = function () {
var i = 0;
if (i <= 30) {
setTimeout(function () {
i++;
ajax("更新数据库")
}, 1000);
}
};
你的30秒事件是否执行,ajax是否请求正常,后台代码可有执行
var CContent = $("#txtContent").val();
if (CContent == null || CContent == "" || CContent.length <= 0) {
alert("回复信息不能为空!");
return;
}
if (CContent.length > 1500) {
alert("回复信息不能超过1500字!");
return;
}
$.ajax({
type: "post",
url: "/Action/Ajax.aspx",///这里是处理页面
data: {
action: "saveContentReply",
ContentID: contentID,
companyID: companyID,
userID: userid,
CContent: escape(CContent),
SubID:SubID
},
cache: false,
success: PostCallBack,
error: AjaxFailCallBack
});
}
//保存AJAX回调
function PostCallBack(data) {
if (data == null || data.toString() == null || data.toString() == "" || data.toString().length <= 0) {
alert("添加失败!");
return;
}
if ($("#contentreply").css("display") == "none")
$("#contentreply").css("display", "block");
var content = data.toString().split("^!*@");
$("#replylist").prepend(content[0]);
$("#txtContent").val("");
$("#replynumber").html(parseInt($("#replynumber").text()) + 1)
$("#replynumber1").html(parseInt($("#replynumber1").text()) + 1)
alert(content[1]);
$("#fEmpty").text("");
}
//Ajax发生错误时
function AjaxFailCallBack(XMLHttpRequest, textStatus, errorThrown) {
alert("操作失败");
}
//刷新页面
function RefreshUserContentReply() {
$.ajax({
type: "post",
url: "/Action/Ajax.aspx",
data: {
action: "getContentNewsReply",
ContentID: contentID,
companyID: companyID,
userID: userid,
ReplyID: ReplyID,
SubID:SubID
},
cache: false,
success: PostRefrisehCallBack,
error: AjaxRefrisehFailCallBack
});
}
function AjaxRefrisehFailCallBack(XMLHttpRequest, textStatus, errorThrown) {
}
//刷新页面回调
function PostRefrisehCallBack(data) {
if (data == null || data.toString() == null || data.toString() == "" || data.toString().length <= 0)
return;
var content = data.toString().split("^!*@");
$("#replylist").prepend(content[0]);
ReplyID = content[1];
$("#replynumber").html(parseInt($("#replynumber").text()) + parseInt(content[2]))
$("#replynumber1").html(parseInt($("#replynumber1").text()) + parseInt(content[2]))
}
$(function() {
setInterval(RefreshUserContentReply, 10000);
});
示例处理页接收参数的方法 ajax.aspx
string action = Request.Params["action"].ToString();话到这份上,你必须会了