使用jquery/AAx创建表单


Creating form with jquery/AJax

我在div。。我想要的是当用户提交表格时,经过适当的验证,而不是重定向到其他感谢页面,我只想从该Div中删除联系表格,并向他显示"谢谢"消息

我该怎么做?演示/下载代码将有助于

稍微搜索一下就好了;)

<div id="form>
[ Your HTML Form]
</div>
<script>
$([form]).submit(function () {
   $("#id").html("Thank You");
});
</script>

一个简单、出色且广泛使用的jQuery Form插件:

http://jquery.malsup.com/form/

您可以使用此插件使用ajax提交表单,然后在成功回调时显示适当的响应。

    $("#submitBtn").click(function () {
$("#divId").html("Loading PleaseWait"); //divId contain all the text field
    $.ajax({
                type: "POST",
                data: "data=" + $("#data").val(),   //id of the text field (value)
                url: "demo.php",                    //page name to which u r passing the value
                success: function(msg){
                if($("#divId").html(msg))
                { 
                    $("#divId").html("Thank You");
                }
            }); 
});