ajax异步提交留言并不刷新本页显示出来。
显示留言部分 我是通过JQUERY的ajax调用显示的:
<div id="pmessage">
<script>repmessloading('<%=aum%>');</script>
</div>
function repmessloading(d)
{
$("#pmessage").html("<P style='text-align:center'><img src='lgwimages/loading.gif'>正在加载..</P>")
$.post("lgwinc/ajax_function.asp",{id:d,apart:"pmessloading"},function(result){
$("#pmessage").html(result);
});
}
留言部分也是通过ajax异步提交的:
<p>请留言:</p>
<form name="pmess" method="post"><input name="pnum" id="pnum" value="<%=aum%>" type="hidden" />
<textarea class="txtarea" name="content" id="content"></textarea>
<input type="submit" value="" class="mess" id="pemssbut" onClick="return chkpromess()"/>
<span id="errtxt"></span>
</form>
function chkpromess()
{
if($("#content").val()=="")
{
$("#errtxt").html('请您输入留言内容');
$("#content").focus();
return false;
}
else
{
var d=$("#paum").val();
var con=$("#content").val();
$.post("lgwinc/ajax_function.asp",{id:d,apart:"pmess",content:escape(con)},function(result){
$("#errtxt").html(result);
});
return true;
}
}
远程调用asp文件部分:
sub pmess()
pid=request("id")
if pid="" then
response.Write "服务繁忙,请您稍候再试"
response.End()
end if
con=VbsUnEscape(request("content"))
if con="" then
response.Write "请您输入留言内容"
response.End()
end if
if request.Cookies("vip")("vid")="" or request.Cookies("vip")("vst")="" then
response.Write "请您先登录"
response.End()
end if
set ajax_rs=server.CreateObject("adodb.recordset")
ajax_rs.open "select * from dh_project_message",conn,1,3
ajax_rs.addnew
ajax_rs("content")=con
ajax_rs("vipid")=request.Cookies("vip")("vid")
ajax_rs("projectid")=pid
ajax_rs("checktime")=now()
ajax_rs.update
ajax_rs.close
set ajax_rs=nothing
response.Write "<script>repmessloading("&pid&");</script>"
response.End()
end sub
sub pmessloading()
pid=request("id")
if pid="" then
response.Write "服务繁忙,请稍候再试.."
response.End()
end if
set ajax_rs=server.CreateObject("adodb.recordset")
ajax_rs.open "select * from dh_project_message where projectid="&pid&"",conn,1,1
i=1
do while not ajax_rs.eof
if i mod 2 =0 then
bgstr=""
else
bgstr="bgcolor='#e6e6e6'"
end if
set ajax_rk=server.CreateObject("adodb.recordset")
ajax_rk.open "select * from dh_vip where id="&rs("vipid")&"",conn,1,1
if ajax_rk("sort")=1 then
ctxt="设计师:"&ajax_rk("tname")&"<img src='images/grade"&ajax_rk("grade")&".gif'>"
elseif ajax_rk("sort")=2 then
ctxt="雇主:"&ajax_rk("tname")&""
end if
ajax_rk.close
set ajax_rk=nothing
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0" <%=bgstr%> style="margin-