How to get the sucess message in the same page after submitting the contact form?

前端 未结 5 1454
再見小時候
再見小時候 2021-01-02 11:31

I have created the contact form using HTML and PHP. Also, the mail is coming correctly to mail id. But after the success message, it is redirecting to the form.php

5条回答
  •  走了就别回头了
    2021-01-02 11:48

    getting the error in java script.

    function sendEnquiryform(){
            var fname=$('#fname').val();
            var email=$('#email').val();
            var pd=$('#pd').val();
            var pg=$('#pg').val();
            var ced=$('#ced').val();
            var score=$('#score').val();
            var message=$('#message').val();
            $.post("mail.php",'fname='+name+'&email='+email' +'&pd='+pd' +'&pg='+pg' +'&ced='+ced' +'&score='+score'&message='+message,function(result,status,xhr) } 
                    if( status.toLowerCase()=="error".toLowerCase() )
                    { alert("An Error Occurred.."); } 
                    else { 
                        //alert(result);
                        $('#sucessMessage').html(result);
                    }
                })
                .fail(function(){ alert("something went wrong. Please try again") });
        }
    

提交回复
热议问题