2011-11-26 03:07
浏览 32

CakePHP中的$ _POST相当于ajax调用?

Normally, when I'd do an ajax call to a page with jQuery's $.post(), I'd post to a specific page (i.e. ajax.php) with something like:

var submissionId = 1;
$.post('/ajax/ajax.php', {
        submissionId: submissionId
}, function(data) {

and inside ajax/ajax.php, I'd manipulate the data how I'd want with $_POST['submissionId']. What is the equivalent to this in CakePHP if I'm posting to a controller?

Do I still use $_POST['submissionId'] or $this->data?

If using $this->data, do I need to create a <form> to wrap the event handler in?

图片转代码服务由CSDN问答提供 功能建议

通常情况下,当我用jQuery的$ .post()对页面进行ajax调用时,我会 发布到特定页面(即ajax.php),例如:

  var submissionId = 1; 
 $ .post('/ ajax / ajax.php',{  

并在ajax / ajax.php中, 我用 $ _ POST ['submissionId'] 操纵数据我想要的。 如果我要发布到控制器,CakePHP中的相应内容是什么?

我是否仍然使用 $ _ POST ['submissionId'] $ this-&gt; data

如果使用 $ this-&gt; data ,是否需要创建&lt; form&gt ; 将事件处理程序包装在?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongling4383
    dongling4383 2011-11-26 03:32

    you should create form with cake helper (hide it with css or jquery if you don't want it to be there) and use jquery form plugin
    you can submit the form with jquery with submit()
    so in the controller you can use $this->data

    点赞 评论