function onButtonClick(){
var grid = Ext.getCmp('mygridpanel')
var row = grid.getSelectionModel().getSelection()[0];
var txtVehicleID = Ext.getCmp('txtVehicleID').getValue();
var txtPlat_No = Ext.getCmp('txtPlat_No').getValue();
console.log(txtVehicleID);
var record = UserStore.findRecord('_id', txtVehicleID);
record.set('_id', txtVehicleID);
record.set('Plat_No',txtPlat_No);
UserStore.sync({
success: function(response) {
Ext.MessageBox.show({
title: "Information",
msg: "Update Success !",
icon: Ext.MessageBox.INFO,
buttons: Ext.MessageBox.OK,
fn: function(buttonId) {
if (buttonId === "ok") {
EditWin.close();
}
}
});
},
failure: function(action){
Ext.MessageBox.show({
title: "Information",
msg: "Update Failed !",
icon: Ext.MessageBox.ERROR,
buttons: Ext.MessageBox.OK,
fn: function(buttonId) {
if (buttonId === "ok") {
EditWin.close();
}
}
});
}
});
//console.log("clicked");
}
php返回成功消息字符串
<?php
$data = file_get_contents("php://input");
//echo $data;
//$obj = var_dump(json_decode($data));
$obj = json_decode($data);
$_id = $obj->{'_id'};
$Plat_No = $obj->{'Plat_No'};
mysql_connect("localhost", "root", "Apacheah64") or die("Could not connect");
mysql_select_db("db_shuttlebus") or die("Could not select database");
$query = "UPDATE tbl_vehicle SET Plat_No ='". $Plat_No ."' WHERE _id=".$_id;
if (mysql_query($query)){
echo '{"success":true,"message":"Update Success !"}';
}else{
echo '{"success":false,"message":"Update Failed !"}';
}
?>
如何获取消息并在此处显示msg: "Update Success !"
?
答案 0 :(得分:0)
在UserStore.sync()
配置对象中,尝试定义success
这样的failure
处理程序:
UserStore.sync({
success: function(batch, options) {
var message = batch.proxy.getReader().jsonData.message;
// display success message...
},
failure: function(batch, options) {
var message = batch.proxy.getReader().jsonData.message;
// display error message...
}
});