dream12001 2016-05-04 05:36
浏览 59
已采纳

Laravel Ajax调用删除会话闪存数据

My repeated Ajax call deletes session flash data

I have a Javascript to make an Ajax call it calls my api every 5 seconds to update my user page.

I am returning a view with flash data which it has to keep for the next request but the Ajax call clears it and the next request is not completed.

Is there a way to complete it?

I can think to re-flash on an api call, but that seems weird. Any other way?

  • 写回答

1条回答 默认 最新

  • doubang4881 2016-05-04 06:16
    关注

    Since your ajax call needs access to the session information, you have to load the session, which will count as your access to the flash data. You will need your ajax call to reflash the data.

    There is a reflash method on the session that will take care of this for you. You can either call it in the Controller method that handles your ajax call, or better yet, create a new middleware that reflashes session data, and attach the middleware to any route that needs this functionality.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办