---
title: "表单异步提交"
author: "lihaiming"
date: "2014-12-25T18:01:43Z"
tags: ["AjaxSubmit"]
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2014-12-25T18:08:44Z"
id: 2170140
url: "https://lihaiming.iteye.com/blog/2170140"
---

表单提交方式：

```js

//ajaxSubmit
var options ={   
                    url:'xxxx.action',   
                    type:'post',                    
                    data:null,
                      success:function(data){
                        if(data.statusCode=="OK") {  
         
                           
                    }else{

                    } 
                    }   
                 };
               var form =$("form[name=form1]");//form1:表单ID  在表单界面只用这一个表单ID
            	   
              form.ajaxSubmit(options); 
//ajax方式
$.ajax({
                cache: true,
                type: "POST",
                url:ajaxCallUrl,
                data:$('#yourformid').serialize(),// 你的formid
                async: false,
                error: function(request) {
                    alert("Connection error");
                },
                success: function(data) {
                    $("#commonLayout_appcreshi").parent().html(data);
                }
            });
//可以用load来post 整个form，用serialArray(),如： 
$('#submit_button').click(function(event) {

$(this.form).load(
this.form.action,
$(this.form).serializeArray());

event.preventDefault();
this.disabled = "disabled";
});

```

以下是ajaxform的传送门，有兴趣可以看下
<http://plugins.jquery.com/form/>
doc
<http://jquery.malsup.com/form/#ajaxForm>