jquery ajax 應用執行個體

來源:互聯網
上載者:User

jquery ajax 應用執行個體<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>jquery ajax 應用執行個體</title>
<script language="網頁特效">
$(document).ready(function(){
    var a={};$(".followpreview").mouseo教程ver(function(){
        var h=$(this);var b=h.attr("id"),d=h.offset().left,j=h.offset().top+h.height(),g="";var e=$("body").width();
        if(e-d<210){d=d-186;g="followerpreviewboxarrright"}else{g="followerpreviewboxarrleft";}
        a[b]=window.settimeout(function(){
            var l="box"+b;var k=b.replace("fu","");
            if(document.getelementbyid(l)==null){
                $("body").append('<div class="followerpreviewbox" id="'+l+'"></div>');
                $("#"+l).css教程({left:d,top:j}).fadein(500);
                $.ajax({type: "get",url:  webaddr+"/www.111cn.net/ajax.php教程?act=getuserinfo&uid="+k+"&class="+g+"&rank="+getrandomnum(1,999999),success: function(msg){$("#"+l).html(msg).css("backgroundimage","none");}});
            }else{$("#"+l).fadein(500)}},500);function c(){var l=$(this).attr("id");window.cleartimeout(a[l]);var k="box"+l;$("#"+k).fadeout(500)}}
         ).mouseout(function(){var c=$(this).attr("id");window.cleartimeout(a[c]);var b="box"+c;$("#"+b).hide()})});
</script>
</head>

<body>

ajax.php 檔案
<?php
$api=1;
include('../common.inc.php');

//發送私信
if($action=='send') {
 $content = trim($_post["content"]);
    $funame = $_post["funame"];
    $user=user_info("user_name='$funame'");
    if (!$user['user_id']) {
        echo '您發送的使用者不存在';
        exit;
    }
 if (!empty($content)) {
        $content=getsubstrutf8($content,0,140,false);
        $content=replace($content);
        $content=daddslashes($content);

        $db->query("update et_users set priread = priread+1 where user_id='$user[user_id]'");
        $db->query("insert into et_messages (senduid,sendname,sendnickname,sendhead,sendtouid,sendtoname,sendtonickname,messagebody,sendtime) values ('$my[user_id]','$my[user_name]','$my[nickname]','$my[user_head]','$user[user_id]','$user[user_name]','$user[nickname]','$content','$addtime')");
        echo 'success';
        exit;
    } else {
        echo '您沒有填寫發送的內容,返回重新填寫';
        exit;
    }
}

if ($act=='getuserinfo') {
    $uid=$_get['uid'];
    $class=$_get['class'];
    $userquery = $db->query("select nickname,user_head,lastcontent,lastconttime from et_users where user_id='$uid'");
    $user=$db->fetch_array($userquery);
    $head=$user['user_head']?"$webaddr/attachments/head/".$user['user_head']:"$webaddr/images/noavatar.jpg";
    $content=simplecontent($user[lastcontent]);

    $time=$user[lastconttime]?timeop($user[lastconttime]):"";
    echo '<div class="'.$class.'"></div><table width="200" border="0" cellpadding="0" cellspacing="0"><tr><td width="53" rowspan="2" align="left" valign="top"><img src="'.$head.'" width="48px" /></td><td><strong>'.$user[nickname].':</strong>'.emotionrp($content).'</td></tr><tr><td class="followtime">'.$time."</td></tr></table>";
    exit;
}

if ($act=='getreplycontent') {
    $contid=$_get['contid'];
    $contdata=getreply($contid);
    if ($contdata) {
        $contents=ubb($contdata['content_body']);
        echo '<div class="status_reply_list">
            <div class="top"></div>
            <div class="cont">
            <h1 class="line">以下是原文:<a href="'.$webaddr.'/op/view/'.$contid.'">原文回複('.$contdata['replytimes'].')</a></h1>
            <div class="replyajaxbox"><a href="'.$webaddr.'/'.$contdata['user_name'].'">'.$contdata['user_nickname'].'</a>:'.$contents.'</div>
            </div>
            <div class="bottom"></div>
            </div>';
    }
}
?>

</body>
</html>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.