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("修改失败"); }

}
});
}
调试了好久发现没有反应,不知道各位能不能帮忙看一下是哪里有问题吗?
...全文
930 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
sscqq1 2017-06-08
  • 打赏
  • 举报
回复
搂了一眼 data: "{ZWH:'" + ZWH + "',BH:'" + BH + "'}" 改为data: {ZWH:ZWH,BH:BH}; 把 contentType和 beforeSend 两行都去掉; 确认url路径是否正确; 再有错 开F12自己看
Go 旅城通票 2017-06-08
  • 打赏
  • 举报
回复
自己f12打开浏览器开发工具看控制台报什么错误

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧