这篇文章主要介绍了如何利用ajax异步处理POST表单中的数据,下面有个不错的示例,大家可以参考下
//防止页面进行跳转
02
03
$(document).ready(
function
(){
04
$(
"#submit"
).click(
function
(){
05
var
str_data=$(
"#form1 input[type=text]"
).map(
function
(){
06
return
($(
this
).attr(
"name"
)+
'='
+$(
this
).val());
07
}).get().join(
"&"
);
08
var
box_data=$(
"input[type=checkbox]:checked"
).map(
function
(){
09
return
($(
this
).attr(
"name"
)+
'='
+$(
this
).val());
10
}).get().join(
"&"
);
11
var
race=$(
"#race"
).val();
12
var
volume=$(
"#volume"
).val();
13
str_data+=
"&volume="
+volume;
14
str_data+=
"&race="
+race;
15
str_data+=
"&"
+box_data;
16
$.ajax({
17
type:
"POST"
,
18
url:
"deal.php"
,
19
data:str_data,
20
success:
function
(msg){
21
$(
"#myModal .modal-body"
).html(msg);
22
}
23
});
24
});
25
});
更多信息请查看IT技术专栏