2013-12-09 89 views
1
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返回成功信息字符串如何從store.sync()獲取返回消息;

<?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

在你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... 
    } 
}); 
相關問題