關於表單 AJAX 提交方式;

<form method="post" id="upfrm" action="UPDATE_ACTION">

<input id="oldPwd" type="text" />

<input id="newPwd" type="text" />

<input type="button" value="提交"  οnclick="update();"/>

</form>


.js--------------------------------------

function update(){

var options = {
 dataType: 'json',
iframe: false,
success: function(data) {
if(data.success){
alert("修改成功!");
}else{
alert(data.errors.errmsg);
}
}
};
$.ajaxSetup({contentType:'application/x-www-form-urlencoded;charset=utf-8'});
$('#upfrm').ajaxSubmit(options);

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章