第一步引用需要的js,具体网上一大把
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://malsup.github.io/jquery.form.js"></script>
第一种在方法体内定义 option 属性
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://malsup.github.io/jquery.form.js"></script>
第一种在方法体内定义 option 属性
$(
"#form1"
).ajaxSubmit({
type: "post", url: "saveGuestFollow",//默认是form action
dataType:
"json"
,
data: {
"filename"
: $(
"#fuldDoc"
).val() },
success:
function
(data) {
if
(data.status == 0)
$(
"#txtDoc"
).val(data.url);
$(
"#lblTip"
).text(data.msg);
},
error:
function
() {
$(
"#lblTip"
).text(
"系统出现错误,请联系管理员"
);
}
});
第二种定义 option
var ajax_option= { type: "post", url: "saveGuestFollow",//默认是form action dataType: "json", success: function (data) { } ,error: function () { $("#lblTip").text("系统出现错误,请联系管理员"); } } $('#saveGuestFollow').ajaxSubmit(ajax_option); 其他 默认是 type提交方式是get $(this).resetForm(); // 提交后重置表单