donglanzhan7151 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) {
alert(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?

  • 写回答

1条回答 默认 最新

  • 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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。
  • ¥15 stm32的can接口不能收发数据
  • ¥15 目标检测算法移植到arm开发板
  • ¥15 利用JD51设计温度报警系统