MVC简单ajax请求

 MVC简单ajax请求

 

@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script>
        $(function () {
            $("#btnOK").click(function () {
                $.ajax({
                    type: "post",
                    dataType: "json",
                    url: "/WriteLog/WriteLog4netInfo",
                    data: {

                    },
                    success: function (data) {
                        alert("成功返回" + data);
                    },
                    error: function (data) {
                        alert("请求发送失败");
                        alert(JSON.stringify(data))
                        return;
                    }
                });
            });
        })
    </script>
</head>
<body>
    输入搜索内容,显示相关数据:<input id="shopCode" />
    <button id="btnOK">搜索</button>
    <br />

    <table id="dataTable">
        <tr>
            <td></td>
        </tr>
    </table>
</body>
</html>

 

posted on 2022-10-28 17:30  Jankie1122  阅读(12)  评论(0编辑  收藏  举报