Trying to work with AJAX & PHP

前端 未结 1 583
北恋
北恋 2021-01-27 02:35

I haven\'t worked with AJAX much but what I\'ve been attempting to do is have a form where a user enters data, click submit and instead of refreshing the page for t

相关标签:
1条回答
  • 2021-01-27 03:10

    So your problem is that the page is reloading even though it should not? I assume you are using jQuery? Try to write your form submit handler like this:

    frm.submit(function (e) {
        if (e) {e.preventDefault()};
        //...
    });
    

    As far as I remember, returning false only works if you attach handlers the old-fashioned way, in jQuery you have to explicitly suppress the default action of the event triggered by the form submit.

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