how to use ajax function to send form without page getting refreshed, what am I missing?Do I have to use rest-framework for this?

后端 未结 11 2215
花落未央
花落未央 2021-01-05 03:37

I\'m trying to send my comment form using ajax, right now when user inserts a comment then whole page gets refreshed. I want this to be inserted nicely without page getting

11条回答
  •  耶瑟儿~
    2021-01-05 04:13

    In your javascript, you call for the class .commentForAjax. You should call the ID:

    $(document).on('submit','#commentForAjax', function(e){
        // ...
    });
    

    Hope this helps. R

提交回复
热议问题