提交给phppage的html表单不返回值,而是在页面本身打印

时间:2013-06-27 10:52:28

标签: jquery ajax return echo

我使用jquery

提交了一个表单

使用以下格式(HTML表格)

$(document).ready(function () {       
    $("#form_submit").click(function() {
        $("#RegisterUserForm").trigger('submit'); 
    }); 

    $("#RegisterUserForm").validate({ 
        onkeyup: false, 
        submitHandler: contact_submit 
    });

    $('#verificationcode').attr('value', '');

    function contact_done() { 
        window.location = '/'; 
    }
    function contact_submit() {
        $.ajax({
            type: "POST",
            url: "thankyou.php",
            data: $("#contact_form").serialize(),
            success: function(data){
                if (data == "SUCCESS")
                    alert('sucess');    
                else if (data == "BADCODE")
                    alert("The security code you typed was wrong. Please try again.");
                else
                    //alert("Message not sent, please try again. Error data: "+data);
            }
        });
    }
});

php代码是:

sendmail(params)
{ 
    echo "SUCCESS";
} 
else 
{      
    echo "BADCODE";
} 

在iframe中我提交表单但是在页面中打印值Success或badcode而不返回jquery表单

0 个答案:

没有答案