jquery getJSon  load $.ajax写法实例

jackxiang 2009-11-13 17:50 | |
Load比较简单:

$("#have_votes_to_vote").load("/con/vote/act/hasleft",{clientTime:Date()},
       function(data){if(data==""){$(this).text('0')}}
  );


http://xxx.xxx.com/con/vote/act/hasleft:

<?php
$content = json_encode ( array ("code" => "1", "message" => "成功!",'votehasleft'=>$result[0]['FViewCount']) );
echo $content;
?>


getJSON:
PHP

<?php require './script.php';?>
<label   id="have_votes_to_vote" class="have_votes_to_vote"></label>
<script language="javascript">

$.getJSON('http://xxx.xxx.com/con/vote/act/hasleft',function(data){alert(data.message);$("#have_votes_to_vote").text(data.message);});
</script>




$.ajax的写法:

    var noMiniPic = $.ajax({
        url: "/con/user/act/checkmini",
        data:"clientTime="+Date(),
    async: false
        }).responseText;
    if(parseInt(noMiniPic)==1)
    {
        alert('ÎÂÜ°Ìáʾ£ºÇëµã»÷ÉÏ´«£¬ÔÙÌá½»×¢²áÐÅÏ¢');  
        return false;
    }





参考:http://www.cnblogs.com/yeer/archive/2009/07/23/1529460.html
         http://www.ibm.com/developerworks/cn/xml/x-ajaxjquery.html

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/2213/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2009-11-20 10:15
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]