菜鸟教程地址:

http://www.runoob.com/jquery/jquery-ref-ajax.html

 

html(../Home/Index.cshtml)

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <title></title>
    <link type="text/css" href="~/Content/bootstrap.min.css" rel="stylesheet"/>

    <script type="text/javascript" src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="~/Scripts/bootstrap.min.js"></script>
    <script type="text/javascript" src="~/Scripts/Home/Main.js"></script>
</head>
<body>
    <button class="Btn">按钮</button>
</body>
</html>

 

Main.js

$.get()的使用

$(document).ready(function () {
  $(".Btn").click(function () {     $.get("../Home/Index", function (data, status) {     alert("数据:" + data + ";状态:" + status);   });   });
});

 

$.post()的使用

$(document).ready(function () {
    $(".Btn").click(function () {
        $.post("../Home/Index",
            {
                name: "ww",
                url:"http://www.baidu.com",
            }, function (data, status) {
            alert("数据:" + data + ";状态:" + status);
        });
    });
});

 

版权声明:本文为tianhengblogs原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/tianhengblogs/p/5991753.html