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 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥15 在现有系统基础上增加功能