表单1:
简单的表单数据提交:
js代码:
document.form1.action=url; //可以获取form1中的里面的数据提交到后台处理,对的是id+value。
document.form1.submit();
jquery:
post提交multipart/form-data类型的表单:
jQuery.ajax({
url:url,
type: 'post',
/*关键代码块*/
data: new FormData($('#form1')[0]),
processData: false,
contentType: false,
/*关键代码块*/
dataType : "json",
success: function(data){
if(data.success){
showMsgBox('alert',data.info);
} else {
showMsgBox('alert',data.info);
}
},
error: function(response){
showMsgBox('alert',"操作失败");
return false;
}
});