AJAX实现数据库的修改功能
X__U 2017-06-08 02:46:19 function update() {
var ZWH = $("#textZWH").val();
var BH = $("#textBH").val();
$.ajax({
type: "POST", //访问WebService使用Post方式请求
contentType: "application/json;charset=utf-8", //WebService 会返回Json类型
url: "ziyaheWebService.asmx/Update", //调用WebService
data: "{ZWH:'" + ZWH + "',BH:'" + BH + "'}", //Email参数
dataType: 'json',
beforeSend: function (x) { x.setRequestHeader("Content-Type", "application/json; charset=utf-8"); },
error: function (x, e) { },
success: function (response) { //回调函数,result,返回值
if (response.d == true) {
var urlstr = "http://localhost:49963/ziyaheWebService.asmx/GetJCXX3?jsoncallback=?";
$('#tbuserUpdate').datagrid({
title: '用户列表',
iconCls: 'icon-save',
width: 600,
height: 240,
nowrap: true,
autoRowHeight: false,
isajaxEx: true,
striped: true,
collapsible: true,
url: urlstr,
sortName: 'JCZD_ZWH',
sortOrder: 'asc',
remoteSort: false,
idField: "JCZD_ZWH",
frozenColumns: [[
{ field: 'ck', checkbox: true },
]],
columns: [[
{ field: 'JCZD_ZWH', sortable: true, title: '站位号', width: 200 },
{ field: 'JCZD_BH', sortable: true, title: '检测站点编号', width: 100 },
]],
pagination: true,
rownumbers: true,
onSelect: function (index, row) {
var row = $('#tbuserUpdate').datagrid('getSelected');
if (row) {
$("#textZWH").val(row.JCZD_ZWH);
$("#textBH").val(row.JCZD_BH);
}
}
});
$('#tbuserUpdate').datagrid('clearSelections');
alert("修改成功");
}
else { alert("修改失败"); }
}
});
}
调试了好久发现没有反应,不知道各位能不能帮忙看一下是哪里有问题吗?