2013-03-15 51 views
1

我正在extjs + Yii中工作。我的客户端功能在yii中设置,服务器端功能在extjs中。在extjs控制器中我编写了代码发送动态生成存储,设置其代理并使用sync()方法存储。如何通过extjs的store.sync()方法捕获数据发送

review:function() 
    { var reviewQuestionStore=Ext.create('Balaee.store.qb.QbqnsStore'); 
     proxy=reviewQuestionStore.getProxy(); 
     Ext.apply(proxy.api,{ 
      read:'http://127.0.0.1/s_balaee/Balaee/index.php/QuestionBank/Qbpaper/ReviewQuestionPaper', 
      create:'http://127.0.0.1/s_balaee/Balaee/index.php/QuestionBank/Qbpaper/ReviewQuestionPaper', 
     }); 
     Ext.apply(proxy.writer,{ 
      type:'json', 
      root:'records' 
     }); 

     Ext.apply(proxy.reader,{ 
      type:'json', 
      root:'questions' 
     }); 
     var getdata=this.getLocalvalue(); 
      UserId=getdata.data.userId; 

     //Using sync method 
     var check =Ext.create('Balaee.model.qb.QbqnsModel',{ 
        questionPaperNo:Paperno, 
        userId: UserId, 
       }); 
     reviewQuestionStore.add(check); 
     reviewQuestionStore.sync(); 
} 

所以它的工作是正确的。而其发送JSON格式的数据原样

{"records":{"userId":"5","firstName":"abc","middleName":"","lastName":"","languageId":"","primaryEmail":"[email protected]","birthDate":"","password":"","securityQuestionId":"","securityQuestionAnswer":"","isMale":"","creationTime":"","ipAddress":"","confirmationCode":"","userStatusId":"","question":"","id":null}} 

现在,我要赶在警予控制器功能这个数据。我曾试图原样

$postData = json_decode(file_get_contents("php://input"), true); 
     $clientData = $postData['records']; 

和访问我使用$ clientData [“的firstName”]字段。但它不是working.So如何捕捉Yii中的数据是通过ExtJS的的商店同步()方法来发送。

回答

1

使用标准的Yii的Json decode.It将创建数组,你

$data= CJSON::decode(file_get_contents("php://input")); 
+0

感谢名单先生......它的工作原理... – user1722857 2013-03-15 09:32:12

+0

@ user1722857欢迎您 – 2013-03-15 10:36:09

相关问题