Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript PHP无法取消设置会话变量_Javascript_Php_Ajax_Session_Session Variables - Fatal编程技术网

Javascript PHP无法取消设置会话变量

Javascript PHP无法取消设置会话变量,javascript,php,ajax,session,session-variables,Javascript,Php,Ajax,Session,Session Variables,我无法取消设置搜索筛选器上使用的会话变量。单击domain.com/index.php?filter=clear时,不会发生任何事情,并且过滤器不会被清除 我混合使用php和JS使用AJAX更新表 PHP: /** * Clears the current filter */ function clear() { unset($_SESSION['filter']); // Clear current page unset($_SESSION['arctic_pag

我无法取消设置搜索筛选器上使用的会话变量。单击domain.com/index.php?filter=clear时,不会发生任何事情,并且过滤器不会被清除

我混合使用php和JS使用AJAX更新表

PHP:

/**
 * Clears the current filter
 */
function clear()
{
    unset($_SESSION['filter']);

    // Clear current page
    unset($_SESSION['arctic_page']);
}
clear: function()
{
    // Show loading image
    new Element('img', { src: '/images/loading.gif' }).setStyle('float', 'right').injectTop(Issues.container.getElement('h2'));

    // Create AJAX request
    new Ajax('index.php',
    {
        method: 'get',
        data: 'ajax=true&filter=clear',
        update: 'issue_list',
        onComplete: Issues.initialise
    }).request();
}
}

JS:

/**
 * Clears the current filter
 */
function clear()
{
    unset($_SESSION['filter']);

    // Clear current page
    unset($_SESSION['arctic_page']);
}
clear: function()
{
    // Show loading image
    new Element('img', { src: '/images/loading.gif' }).setStyle('float', 'right').injectTop(Issues.container.getElement('h2'));

    // Create AJAX request
    new Ajax('index.php',
    {
        method: 'get',
        data: 'ajax=true&filter=clear',
        update: 'issue_list',
        onComplete: Issues.initialise
    }).request();
}

它看起来像是原型JS,对吗?我已经有一段时间了,但我认为这是正确的语法:

new Ajax.Request('index.php',
{
    method: 'get',
    data: 'ajax=true&filter=clear',
    update: 'issue_list',
    onComplete: Issues.initialise
});

您是否添加了
session_start()在顶部?是,会话_开始();包含在my init.php中(在加载筛选器之前)您是否在主页上获得与ajax请求相同的会话ID?您在哪里调用
clear()
函数?是的,我返回相同的会话ID。以及clear()函数位于超级链接domain.com/index.php?filter=clear上,该函数似乎也不起作用。事实上,我使用的是一个稍微修改过的北极虫子跟踪器