我已经在我的桌子上砸了几天了......我请求帮助。
我正在尝试更新Kendo UI网格中的值。网格显示正确,弹出编辑器也是如此。那是美好时光结束的地方。情况如下:
这是我的剑道代码:
$(document).ready(function () {
var crudServiceBaseUrl = "assets/data/",
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "data.clients.php",
},
update: {
url: crudServiceBaseUrl + "data.clients.update.php",
},
create: {
url: crudServiceBaseUrl + "data.clients.create.php",
},
parameterMap: function(options, operation) {
if (operation !== "read" && options.models) {
return {models: kendo.stringify(options.models)};
}
}
},
batch: true,
pageSize: 10,
error: function(e) {
alert(e.responseText);
},
schema: {
data: function(result) {
return result.data || result;
},
total: function(result) {
var data = this.data(result);
return data ? data.length : 0;
},
model: {
id: "clientID",
fields: {
clientID: { editable: false, nullable: true },
clientName: { validation: { required: true } },
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
toolbar: ["create"],
columns: [
{ field: "clientID", title: "Client ID" },
{ field: "clientName", title: "Client Name"},
{ command: "edit", title: " ", width: 110 }],
editable: "popup"
});
});
这是我的PHP:
include '../includes/connect.php';
$clientName = mysql_real_escape_string($_POST["clientName"]);
$clientID = mysql_real_escape_string($_POST["clientID"]);
$rs = mysql_query("UPDATE cms_clients SET clientName = '" .$clientName ."' WHERE clientID = " .$clientID);
if ($rs) {
echo json_encode($rs);
}
else {
header("HTTP/1.1 500 Internal Server Error");
echo "Update failed for EmployeeID: " .$clientID;
}
哦,我知道这段代码存在潜在注入问题。那是第2步。
任何帮助都将不胜感激。
谢谢, @rrfive