2012-01-03 61 views
0

我使用Cake 2.0製作jQuery Mobile應用程序,但無法將表單提交給控制器操作。在AJAX調用中沒有使用debug()的結果

似乎表單正在提交,但我沒有得到任何結果,當我做debug($this->request->data)

這是因爲它提交爲AJAX?如果是這樣,我該如何解決它,以便我可以接收表單輸入到控制器並返回它們?

回答

1

調試應該顯示的數據和它不依賴於請求類型,你需要在你的配置/ core.php中合適的值,如:

 

Configure::write('debug', 2); // in your Core.php file 

//then in your Controller's some function 
$this->layout = "ajax"; 
if($this->request->is("ajax")) { 
    debug($this->request->data); // should display all your request data 
} 
 

希望它可以幫助

1
$this->request->data 

用於訪問已發佈的數據。

$this->request->query 

是用來顯示你的GET數據

確保您的Ajax調用使用POST做,如果你想使用$this->request->data保持不了。如果您想查看整個請求對象,則只需debug()即可,而不是$this->request

祝你好運!