submit the form using ajax

后端 未结 8 903
栀梦
栀梦 2020-12-05 10:17

I\'m developing an application (a kind of social network for my university). I need to add a comment (insert a row in a specific database). To do this, I have a HTML form in

8条回答
  •  执念已碎
    2020-12-05 10:57

    It's much easier to just use jQuery, since this is just a task for university and you do not need to save code.

    So, your code will look like:

    function sendMyComment() {
        $('#addComment').append('');
        $.ajax({
            type: 'POST',
            url: $('#addComment').attr('action'),
            data: $('form').serialize(), 
            success: function(response) { ... },
        });
    
    }
    

提交回复
热议问题