Submit a php form and display its result on div without reloading page

前端 未结 5 464
北恋
北恋 2021-02-04 22:25

First of all, thank you for your kind help.

I have tried almost everything I found on stackoverflow but I cannot get this to work.

I created a form to send a te

5条回答
  •  遥遥无期
    2021-02-04 23:15

    Can you try this,

     $(".result").html(response);
    

    instead of

     $(".result").appendTo(response)
    

    Jaavscript:

    $(document).ready(function(){
        $('#contact-form').submit(function() {             
            $.ajax({ 
                type:"POST",
                url:"sendtext.php",
                data: $("#contact-form").serialize(),
                success: function(response){
                     $(".result").html(response);
                }
    
            });
            return false;
        });        
    });
    

提交回复
热议问题