一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

jquery AJAX无刷新评论实例

时间:2010-08-12 编辑:简简单单 来源:一聚教程网





jquery ajax无刷新评论


css教程" href="style.css" />



 
网友评论

 

 
 

 

    

    
    

   
     验证码
    

    
   

     
    

 





<%

<%
dim action, id, page, pagehtml, pages, linkhtml
pages = 5
action = request.querystring("action")
id = request.querystring("id")
page = request.querystring("page")
select case action
    case "ajax_getcomment"
        ajax_getcomment()
    case "ajax_sendcomment"
        ajax_sendcomment()
    case else
        echo("erro")
end select

function ajax_getcomment()
    dim temlist, getlist
    openconn(dbpath)
    sql = "select commentuser,commentdate,commenttext,commentreply from comment where commentparentid="&id&" order by commentid asc"
    call openrs(sql, 1)
    if not(rs.bof and rs.eof) then
        rs.pagesize = pages
        rscount = rs.recordcount
        pagenum = rs.pagecount
        page = clng(page)
        if page < 1 then page = 1
        if page > pagenum then page = pagenum
        rs.absolutepage = page
        k = 1
        do while not rs.eof
            temlist = " 

"&vbcrlf
            temlist = temlist& "   
"&rs(0)&" 发表于 "&rs(1)&"
"&vbcrlf
            temlist = temlist& "   
"&rs(2)&"
"&vbcrlf
            if rs(3)<>"" then
                temlist = temlist& "   
回复:"&rs(3)&"
"&vbcrlf
            end if
            temlist = temlist& " 
"&vbcrlf
            k = k + 1
            rs.movenext
            getlist = getlist & temlist
            if k > pages then exit do
        loop
    else
        echo ("暂无评论内容")
    end if
    closers()
    closeconn()
    '显示分页相关信息
    if rscount>0 then
        pagehtml = "
已有"&rscount&"条评论 {$link_list$}
"
        if pagenum>1 then
            for i = 1 to pagenum
                linkhtml = linkhtml & iif(i = page, ""& i &" ", "" & i & " ")
            next
        else
            linkhtml = ""
        end if
        pagehtml = replace(pagehtml, "{$link_list$}", linkhtml)
    end if
    echo (getlist&pagehtml)
end function

function ajax_sendcomment()
    dim commentparentid, commentuser, commenttext, commentvalidate
    openconn(dbpath)
    commentparentid = request.querystring("commentparentid")
    commentuser = unescape(request.querystring("commentuser"))
    commenttext = unescape(request.querystring("commenttext"))
    commentvalidate = unescape(request.querystring("commentvalidate"))
    if cstr(session("getcode"))<>commentvalidate then
        echo ("error")
        response.end()
    else
        sql = "insert into comment(commentparentid,commentuser,commenttext,commentreply,commentip) values('"&commentparentid&"','"&commentuser&"','"&server.htmlencode(commenttext)&"','','"&getip()&"')"
        set rs = conn.execute(sql)
        closers()
        closeconn()
        echo ("评论发表成功.")
    end if
end function
%>

%>
文章无刷新评论代码,如果你想让ajax加载评与ajax发送评论话就下载吧

热门栏目