How to have user submit text in form and AJAX it to enter to db and show up on same page?

前端 未结 3 1290
面向向阳花
面向向阳花 2021-01-27 05:58

I want the user to fill it out. Submit it, have it store into the database and then use jquery to have it show up on the same page in front of them. Right now I can get it to se

3条回答
  •  太阳男子
    2021-01-27 06:22

    You can use a javascript function (using jquery) to handle those events. This method does not use a button, so you will need to create your own button that will call the following function:

    function postPage() {
        $.post("post.php", $("#form_id").serialize(), function(){
            $("#display_id").load('display.php');
        });
    }
    

    You will need to have the post values processed in this case by "test.php", and then the contents of which you want to display back to the user after posting in display.php. The contents of display.php will be placed inside a div/container with the id of "display".

提交回复
热议问题