您好,我是一名使用jQuery和Ajax的新手。我正在嘗試使用Jquery POST方法將數據提交給服務器。我傳遞的數據是一個字符串。現在我無法理解如何傳遞數據以及如何檢索數據。我試過爲我的問題搜索文章,但我沒有找到。我相信我的問題是非常基本的。將數據從jQuery傳遞到PHP以獲得ajax帖子
if (1)//validateStep(step)
{
if(step==1)
{
var data = document.getElementById('hiddenContact').value;
$.post('/callcenter/admin/postContacts', data);
}
}
現在我將發佈我的postContacts操作的代碼,這不是一件大事。
function postContacts()
{
$this->autoRender = false;
echo '<script>console.log("post contacts");</script>';
}
但我很困惑,如何將數據必須被檢索。任何幫助表示讚賞。我正在使用cakePHP,所以我必須使用autoRender = false;這使得視圖是可選的。