我在__construct()中设置全局变量;Codeigniter:Ajax请求,控制器中的全局变量
function __construct()
{
parent::__construct();
//variables
$this->galleryID = $this->uri->segment(3);
$this->productID = $this->uri->segment(4);
}
从下拉菜单中选择后,我发出ajax请求。
$.ajax(
{
type: 'POST',
url: '/beta/checkout/getCoverSizes',
data: {
column: size
},
dataType: 'json',
success: function (json)
{
console.log(json);
}
});
而在这一点上,简单地输出全局变量
public function getCoverSizes()
{
print_r($this->productID);
}
目前没有什么是$这个 - > ProductID等于返回0,我肯定它是作为函数的索引正确的是()取决于在这个变量上并且正在渲染数据。 ajax请求似乎没有访问全局变量$ this-> productID。
。在你的代码中没有任何全局变量 – zerkms