I am trying to send data over to a cakephp (mvc) website, via $.post(). below is the code
$('#testReq').click(function(){
console.log('Button Works');
$.post('http://play.anthonylgordon.com/usersessions/store/', {data:'test7'},function(data)
{
//data contains the json object retrieved.
console.log(data.status);
},"json"); })
Below is the cakephp data that retrieves the data and stores it. If you know cake, great but if not it's fine. I am really trying to figure out if i am sending the data correctly
<?php
class UsersessionsController extends AppController {
var $name = 'Usersessions';
var $helpers = array('Html', 'Form','Ajax');
var $components = array('RequestHandler');
function store()
{
Configure::write('debug', 0);
$this->autoRender = false;
echo 'hello';
if ($this->params['url']['data'])
{
$this->data['Usersession']['data'] = $this->params['url']['data'];
$this->Usersession->Save($this->data);
echo 'Success';
}
}
}
?>
as you can see I put 'hello' before it does any evaluating. I should be able to see that in my console but I dont. I tried this method with the get and I did see the response 'hello'. which is leaving me to the conclusion that you can not send data CROSS domain via $.post. only method that seems to work is getJSON(). unless someone can prove me wrong enter code here