相关疑难解决方法(0)

jQuery POST到CakePHP $ this-> data

我正在尝试使用jQuerys post-function将表单发布到CakePHP脚本.

像这样:

jQuery的:

$('#submit_btn').click(function(){

   //Code to prevent redirect

   dataString = 'test=testdata';

   $.post('cakephp/forms/output', dataString, function(response){
      alert(response);
   })
});
Run Code Online (Sandbox Code Playgroud)

CakePHP的

function output(){
   pr($this->data);                # Print nothing
   pr($_POST);                     # Print test => testdata 
   $this->render('view','ajax');   # Render ajax-friendly
}
Run Code Online (Sandbox Code Playgroud)

所以$_POST不是空的但是$this->data......怎么样?

发布数据的表单元素i来自aja,如果这是在这种情况下重要的事情.

jquery post cakephp-1.3

3
推荐指数
1
解决办法
6145
查看次数

标签 统计

cakephp-1.3 ×1

jquery ×1

post ×1