我在 __construct(); 中设置全局变量;
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);
}
目前没有什么是 $this->productID 返回 0,我很肯定它是正确的,因为函数 index() 取决于此变量并正确呈现数据。ajax 请求似乎没有访问全局变量 $this->productID。