2013-12-09 3 views
1
var UserStore = Ext.create('Ext.data.JsonStore', { 
    model: 'VehicleModel', 
    autoLoad: true, 
    proxy: { 
     type: 'ajax', 
     url: 'get-vehicle.php', 
     api: { 
       create: 'insert-vehicle.php', 
       //read: 'http://visual04/ModuleGestion/php/Pays.php?action=read', 
       update: 'update-vehicle.php', 
       //destroy: 'http://visual04/ModuleGestion/php/Pays.php?action=destroy' 
        success: function(action){ 
          Ext.MessageBox.show({ 
          title: 'Information', 
          msg: action.result.message, 
          buttons: Ext.Msg.OK, 
          icon: Ext.MessageBox.INFO 
         }); 
        }, 
        failure: function(action){ 
          Ext.MessageBox.show({ 
          title: 'Error', 
          msg: action.result.message, 
          buttons: Ext.Msg.OK, 
          icon: Ext.MessageBox.ERROR 
         }); 
        } 
      }, 

     reader: { 
      type: 'json', 
      idProperty: '_id' 
     }, 
     writer: { 
      type: 'json', 
      id: '_id' 

     } 
    } 
}); 

이 PHP를 업데이트 성공 반환스토어 업데이트 API의 reponse 성공과 실패

<?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 !"}'; 
} 

?> 

이 불을 지르고 성공을 보여 주었다,하지만 왜 여전히 메시지 상자를 팝업 할 수없는가? enter image description here

답변

2

당신은 당신이 store.sync() 메서드에 매개 변수로 전달할 구성 객체의 successfailure 핸들러를 정의해야합니다. Doucmentation : http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Store-method-sync

UserStore.sync({ 
    success: function() { 
     // success sync state handler code 
    }, 
    failure: function() { 
     // failure sync state handler code 
    } 
}) 
관련 문제