jquery ajax 弹出框

  <form id="form1" name="form1" method="post" action="">
                           <li><a title="收藏本店" href="javascript:void(0)" id="shopcollection">收藏本店</a></li>
                </form>

<input type="hidden" name="bid" id="bid" value="<%=BrandID %>" />
<script type="text/javascript">
    var rooturl = '<%=host %>';
  
    jQuery("#shopcollection").click(function() {
   
        jQuery.ajax({
            url: rooturl + 'shopcollection.aspx', //后台处理程序
            type: 'post',         //数据发送方式
            dataType: 'json',     //接受数据格式
            data: { bid: jQuery("#bid").val() },         //要传递的数据
            success: update_page //回传函数(这里是函数名)
        });
    });

    function update_page(json) { //回传函数实体,参数为XMLhttpRequest.responseText
      
        if (json == "2") {
            alert('该店铺已经在您的收藏中!');
        }
        if (json == "1") {
            alert('店铺收藏成功!');
        }
        if (json == "0") {
            alert('您还没有登录!');
        }
    }
</script>

处理页面

   protected void Page_Load(object sender, EventArgs e)
    {
        //还没登录
        string rmessage = "0";

        //根据实际情况判断给rmessage赋值
        Response.Write(rmessage);
        Response.End();
        return;
    }

posted @ 2011-03-28 09:20  红鲤鱼与驴与绿鲤鱼  阅读(1305)  评论(0编辑  收藏  举报