日期:2014-05-16 浏览次数:20420 次
//提交表单
function subm(){
var user = $('#frm').serialize();
$.ajax({
url: 'b.php',
type: 'POST',
data:user,
contentType:"application/json",
dataType: 'json',
async:false,
beforeSend: function(){
alert('Error loading PHP document');
},
success: function(result){
alert(result);
}
});
}
<form id="frm" action="" method="post" onsubmit="subm()">
<input
id="user" name="username" /><br />
<input id="password" type="password" name="password" /><br />
<input type="submit" value="提交" /></form>