Ajax请求在cakephp中不起作用

时间:2013-05-13 02:28:33

标签: php javascript jquery ajax cakephp

我正在尝试在cakephp中执行ajax请求 我的提交是#enviar。我的行动是pages/contato

这是我的ajax请求:

$(document).ready(function() {
    $('#enviar').click(function(){
        $.ajax({
            type: 'post',
        url:"<?php echo Router::url(array('controller' => 'pages','action' => 'contato')); ?>",
        })
    })
});

我为简单的alert()更改了$ .ajax,当我点击提交时,这就有效了 我的问题在哪里?

3 个答案:

答案 0 :(得分:1)

更好地更改你的ajax函数中的url: -

$.ajax({
        type: 'post',
    url:"http://localhost/teste/pages/contato"
    })

答案 1 :(得分:0)

使用以下代码将.htaccess文件添加到工作目录:

allow from all

答案 2 :(得分:0)

您是否尝试过使用Html帮助程序和绝对路径?

$.ajax({
    type: 'post',
    url: "<?=$this->Html->url(array('controller' => 'pages',
                                    'action' => 'contato'),
                              true);?>"
});