-2

jQuery AJAXを使用したこの.aspx Webサイトがあります。

ボタンがない場合は、正常に動作します。

AJAX 呼び出しをボタンでラップすると、機能しません。エラー、成功アラート、AJAX リクエスト、コンソールには何も表示されません。止まるだけです。どうしてか分かりません :(

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

    <script>
        $(document).ready(function () {
            $("#button1").click(function () {
                $.ajax({
                    url: 'WebForm1.aspx',
                    success: function (data) {
                        $('#comments').html(data);
                        console.log("success");
                    }
                });
            });
        });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>

        <button id="button1">get recent comments</button>

        <div id="comments" runat="server">

        </div>

    </div>
    </form>
</body>
</html>
4

1 に答える 1