【发布时间】:2016-08-01 14:46:09
【问题描述】:
我正在使用 cakephp Web 应用程序,我在 default ctp file 中创建了一个小的 Ajax function。设置文件现在我想将值数据发送到另一个控制器函数,在 chrome browser network 中显示 Ajax 发布到所需的 url 但在控制器中当我尝试回显 $_post ['selectedlocation'] 时未显示值??
Ajax 默认文件
var DisplayLocationName = $('#ListingLocation option:selected').val();
$.ajax({
type: "POST",
url: '/listings/home',
data: {selectedlocation:DisplayLocationName },
dataType:"text",
success: function(result) {
}
});
列出控制器功能
function home()
{
if(!isset($this->params['requested']) || $this->params['requested'] != true)
{
$this->actionId = 'home';
}
$this->viewFile = null;
if($this->params['isAjax'] && isset($_POST['selectedlocation']))
{
echo "erreerreer";
echo $selectloc= $_POST['selectedlocation'];
$this->set('selectloc',$selectloc);
}
}
我如何在默认情况下显示 Ajax 发布值以进行测试,以确保 Ajax 向控制器发布正确的值
【问题讨论】:
标签: ajax cakephp controller default