ajax測試程序

記錄一個ajax的一個測試程序

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <% #include virtual="/include/page.html"%>
    </head>
    <body>
        <button class="btn">按鈕</button>

        <script>
            $(".btn").click(function(){
                console.log("ajax func");
                $.ajax({
                    url: 'status.asp',
                    async:true, 
                    dataType: 'json',
                    type: 'post',
                    data:{"StatusType":"2"},
                    success: function(data) {
                     console.log(data);
                      console.log("2");
                    },
                    error: function(xhr, type, errorThrown) {
                        console.log("加載失敗2");
                    }
                });

            });

        </script>

    </body>
</html>
發佈了55 篇原創文章 · 獲贊 22 · 訪問量 24萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章