表单数据的提交
function ajaxAction(){
$.ajax({
type : "POST",
dataType : "json",
contentType : "application/x-www-form-urlencoded;charset=UTF-8",
url : url,//url
data : $("#form1").serialize().concat($("#form2").serialize()).concat($("#form3").serialize()),
beforeSend: function() {
},
success : function(result) {
},
error : function() {
}
});
}
一般JSON数据的异步提交
function addOrder() {
var data = {
"orderID":"",
"number": "",
"customer": {
"cusId": ""
},
"product": {
"productNo": ""
}
};
$.ajax({
type: 'post',
url: 'http://localhost:8080/',
dataType: 'JSON',
contentType: 'application/json',
data: JSON.stringify(data),
success: function(obj) {
},
error: function() {
}
});
}
注意:
contentType: ‘application/json’;这种提交方式的时候,要用JSON.stringify(data), 进行转换不然后台可能接受不到数据