.NET 实现页面点赞功能

26 篇文章 0 订阅
11 篇文章 0 订阅
本文介绍了如何使用.NET技术来实现网页的点赞功能,通过详细步骤和实例代码,阐述了从后端数据库交互到前端jQuery的实现过程。
摘要由CSDN通过智能技术生成
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebTest.WebForm2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="jquery-1.10.2.min.js"></script>
    <script language="javascript" src="http://www.codefans.net/ajaxjs/jquery1.3.2.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <div style="width: 900px; height: 900px; border: 1px solid #ccc; float: left;">
                <span id="ip"></span>
                <span id="add"></span>
            </div>
            <div style="width: 400px; height: 900px; border: 1px solid #ccc; float: left;">

                <div id="test" style="margin-left: 150px; margin-top: 50px; cursor: pointer">
                    <a id="clickzan">
                        <img src="images/2)4CUE6)UI]ZCO@O(YH}`C0.png" /></a>
                </div>
            </div>
        </div>
    </form>
</body>
</html>
<script type="text/javascript">
    $(function () {
        $("#clickzan").click(function () {
            getcookie("userip");
        })
    })
    function getcookie(objname) {//获取指定名称的cookie的值
        var arrstr = document.cookie.split("; ");
        for (var i = 0; i < arrstr.length; i++) {
            var temp = arrstr[i].split("=");
            if (temp[0] == objname) {
                alert("已点赞!");
            } else {
                jQuery(function ($) {
                    var url = 'http://chaxun.1616.net/s.php?type=ip&output=json&callback=?&_=' + Math.random();
                    $.getJSON(url, function (data) {
                        document.cookie = "userip=" + data.Ip;
                    });
                });
                alert("赞!");
            }
        }
    }
</script>


看完记得点赞哦!!


  • 16
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值