在AJAX调用中使用debug()没有结果


No results using debug() in AJAX calls

我正在使用Cake 2.0制作jQuery移动应用程序,但在向控制器动作提交表单时遇到麻烦。

表单似乎正在提交,但是当我做debug($this->request->data)时,我没有得到任何结果。

这是因为它作为AJAX提交吗?如果是这样,我如何解决它,以便我可以接收表单输入到我的控制器并返回它们?

调试应该显示数据,它不依赖于请求类型,您需要在Config/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 } 之前

希望有所帮助

$this->request->data

用于访问post数据。

$this->request->query

用于显示GET数据

如果您想继续使用$this->request->data,请确保您的Ajax调用使用POST而不是GET。如果您想查看整个请求对象,只需在$this->request上执行debug()即可。

祝你好运!