Page refreshes after ajax request

后端 未结 1 1055
深忆病人
深忆病人 2021-01-14 04:37

Alright, I have a simple form comprising of only a text field. Data written in the text field is stored in DB when we hit submit (Stored via ajax). The ajax wor

1条回答
  •  天涯浪人
    2021-01-14 05:03

    Seems that your form is being submitted. Try preventing the default event (i.e. submission):

    $("#submit_message").click(function(e) {
        e.preventDefault();    // This prevents form from being sumbitted
        // the rest of your code
    });
    

    0 讨论(0)
提交回复
热议问题