Hello I am a newbie working with jQuery and Ajax. I am trying submit data to the server using Jquery POST method. And the data that I am passing is a string. Now I am unable to understand how do I pass the data and how do I retrieve the data. I have tried searching for articles for my problem, but I have found none. I believe my problem is very basic.
if (1)//validateStep(step)
{
if(step==1)
{
var data = document.getElementById('hiddenContact').value;
$.post('/callcenter/admin/postContacts', data);
}
}
Now I'll post the code for my postContacts action, which isn't a big thing.
function postContacts()
{
$this->autoRender = false;
echo '<script>console.log("post contacts");</script>';
}
But I am confused as to how the data has to be retrieved. Any help is appreciated. I am using cakePHP, so I have had to use autoRender=false; which makes the view optional.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…