簡體   English   中英

jQuery ajax 不發送響應

[英]jQuery ajax doesn't send a response

我正在向特定的 URL 發送數據,然后我嘗試使用 ajax 獲取它,它只會打印一個錯誤

<script type="text/javascript" src="{{ url_for('static', filename='jquery.js') }}"></script>
<script>
      $(document).ready(function()
    {
    $.ajax({
        method: "POST",
        url: "/computers/{{id}}",
        dataType: "json",
        async: true,
        succsess: function(data){
            var json = $.parseJSON(data); // create an object with the key of the array
            alert(json.html);
            console.log(data)
        },
        error: function(error){
         console.log("Error:");
         console.log(error);
    }
    });
});
</script>

^ 這就是我收到請求的方式(id 為 2)

問題是我沒有發送任何數據,但我也在輸入dataType: "json"所以這導致了錯誤。

$.ajax({
        method: "POST",
        url: "/computers/{{id}}",
        async: true,
        succsess: function(data){
            var json = $.parseJSON(data); // create an object with the key of the array
            alert(json.html);
            console.log(data)
        },
        error: function(error){
         console.log("Error:");
         console.log(error);
    }
    });

所以這是正確的代碼,因為我沒有發送任何數據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM