您的位置:首页 > Web前端 > JQuery

jQuery异步提交与JSON解析

2015-11-17 17:18 721 查看
<script type="text/javascript">
function btn_praise(txtTypeId) {
var txtRowGuidMain = $("#hide_RowGuidMain").val();
var txtUserId = $("#hide_UserId").val();
if (txtRowGuidMain == '' || txtUserId == '') {
alert('对不起,操作失败!');
}
else {
$.ajax({
type: "POST", //用POST方式传输
url: '../AddPriseHandler.ashx', //目标地址
dataType: "json" ,//需要限定
data: { RowGuidMain: txtRowGuidMain, UserId: txtUserId, TypeId: txtTypeId },
success: function (data) {

//此处返回值假设为{"message":"成功","result":16}

alert(data.message);
$(this).attr("value", data.result)
},
error: function () {
alert("异常!");
}
})
}
};
</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: