jquery ajax 弹出框

2023-05-16

  <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;
    }

转载于:https://www.cnblogs.com/yhdkzy/archive/2011/03/28/1997435.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

jquery ajax 弹出框 的相关文章

随机推荐