Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/382.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 收到非活动状态错误-JQuery_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript 收到非活动状态错误-JQuery

Javascript 收到非活动状态错误-JQuery,javascript,jquery,ajax,Javascript,Jquery,Ajax,我有一个Ajax请求,它被发送到一个文件以获取信息并返回JSON 以下是我的请求示例: $.ajax({ url: "admin/actions/ifp_get_events.php", type: "post", dataType: "json", data: { 'elevation_name' : 'global', 'function' : 'elevation_restrictions_events',

我有一个Ajax请求,它被发送到一个文件以获取信息并返回JSON

以下是我的请求示例:

 $.ajax({
    url: "admin/actions/ifp_get_events.php",
    type: "post",
    dataType: "json",
    data:
    {
        'elevation_name' : 'global',
        'function' : 'elevation_restrictions_events',
        'parent_id' : d.ifp_id
    },
    success: function(data){
            ......do stuff
    },
    error:function(){
        alert("error occured, please try again.");
    }
   });
现在我一直在使用Google Chrome进行开发,它工作得非常完美,但当我在Firefox或IE中尝试时,我发现以下错误:

正在触发粗糙警报,我有一个响应文本:

responseText:"
{
    "status":"error",
    "message":"You have been logged out due to inactivity." 
}
{"status":"found","code":1,"original_request":
{"elevation_name":"global","function":"elevation_restrictions_events","parent_id":"26"},"data_retrieved":[{"evt_for":"Game Room","evt_restriction":"","evt_select_ability":"hide","evt_active_ability":"disable"},{"evt_for":"Bedroom 5 w\/ Bath 5","evt_restriction":"Craftsman Entry, Kitchen","evt_select_ability":"show","evt_active_ability":"enable"}]}"
请注意,一旦给出错误消息,新状态部分就是我需要的正确响应。我只是不确定为什么Firefox和IE会出现这种情况

建议、想法

如果您需要更多信息,请询问我。

添加此行:

beforeSend: function (xhr) {
                xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))
            },
在你的数据之后


由于有效的csrf令牌不可用,它会将您从站点注销。

浏览器会话不会在浏览器之间共享。在您的情况下,您登录了Chrome,因此代码按预期工作


但是,在试用FF和IE时,您没有登录,因此输出不同。

换句话说,代码在chrome中运行良好,但在FF和IE中运行不正常?@asprin是的,我不确定为什么我会收到
您已注销…
消息我们需要查看
ifp\u get\u events.php
中的代码,以了解它为什么要将您注销。如果有登录功能,请在两种浏览器上登录应用程序,然后再试一次。如果有登录系统,让我试试,这件事发生在我们中最好的人身上只是其中一天OP没有分享他发送这个csrf令牌的那部分代码,我只是认为这可能是个问题