Get POST data in django form AJAX from

前端 未结 5 645
甜味超标
甜味超标 2021-01-15 19:28

I\'m going to get parameter form AJAX request in Django, Here\'s what I\'m doing:

base.html:

{% csrf_tok
5条回答
  •  旧时难觅i
    2021-01-15 19:59

    Instead of using a click handler, you could setup a more robust form submit function to do the same thing. Returning false cancels the default submit behavior.

    $("form").submit(function() {
        $.post("/", {
            name: "MY TEXT",
        });
    
        return false;
    });
    

提交回复
热议问题