Reputation: 2047
I'm trying to do an ajax request in cakephp.
My submit is #enviar
. My action is pages/contato
.
This is my ajax request:
$(document).ready(function() {
$('#enviar').click(function(){
$.ajax({
type: 'post',
url:"<?php echo Router::url(array('controller' => 'pages','action' => 'contato')); ?>",
})
})
});
I change the $.ajax for a simple alert()
and when i click submit this works.
Where is my problem?
Upvotes: 0
Views: 917
Reputation: 73
Better change the url, in your ajax function :-
$.ajax({
type: 'post',
url:"http://localhost/teste/pages/contato"
})
Upvotes: 1
Reputation: 4522
Have you tried with Html helper and an absolute path?
$.ajax({
type: 'post',
url: "<?=$this->Html->url(array('controller' => 'pages',
'action' => 'contato'),
true);?>"
});
Upvotes: 0
Reputation: 9968
Add an .htaccess file to the working directory with the following code:
allow from all
Upvotes: 0