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());
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题