dongyi7669 2014-11-04 14:35
浏览 47
已采纳

在共享主机上使用jquery重新加载vs刷新页面

enter image description here

I am working with codeigniter and jquery. I am using ajax to send some info to a codeigniter function to perform a db operation , in order to update the page.

                  $.ajax({
                        type: "POST",
                        url: BASE_URL+"Update/update",
                        data:{ i : searchIDs, m : message },
                        dataType: 'json',
                        success: function(data) {
                            console.log(data);                              

                        },
                        error: function(data) {
                            console.log(data);
                        },
                        complete: function() {
                            alert("REFRESHING..");

                         window.location.href = "pan_controller/reply";
                        }
                });

After the operation is complete I want to reload the page. This works normally in locally on my WAMP. However when I deploy to a shared host I usually have to reload the page manually, (using the reload button in the browser -- screenshot above). I see no errors in firebug. I've tried a variety of fixes but have recently started to wonder if this is a caching issue on my shared hosting server. If so is there a better way to reload using jquery rather than just redirect so as to avoid a cache on the shared host?

  • 写回答

1条回答 默认 最新

  • dongshan4878 2014-11-04 14:40
    关注

    Have you established that the complete function is running in those cases when the page doesn't reload? If so then I think you are right, it's a caching problem.

    You can try adding a timestamp parameter to the end of the window.location.href value to make it unique each time and avoid any issues with caching, although a better approach would be to send the correct headers back with the response, so that the browser knows not to cache that page.

    window.location.href = "pan_controller/reply?t=" + (new Date().getTime());
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证