Ajax not work in Django post

前端 未结 4 511
温柔的废话
温柔的废话 2021-01-17 01:53

I\'m trying to use ajax in Django to post comment in a news website.However it doesn\'t work.When I click the submit button,it still refreshes the page and make no d

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-17 02:45

    Add click event on button not on form and You have to change that to button implicitly. By default the type of a button is submit.

    Remove id of form. Submit button submits form-data and reload the page.

提交回复
热议问题