简体   繁体   English

无法清除临时存储

[英]Failed to clear temp storage

Failed to clear temp storage: It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources.无法清除临时存储:确定在 Web 应用程序中访问某些文件不安全,或者对文件资源进行了过多调用。 SecurityError安全错误

I'm getting this error in console.我在控制台中收到此错误。 I have a script name script.js which makes ajax calls to retrieve data from php.我有一个脚本名称 script.js,它进行 ajax 调用以从 php 检索数据。

Any idea why?知道为什么吗?

Here's my jQuery script这是我的 jQuery 脚本

$(document).ready(function() {

  var loading = false;
  var docHeight = $(window).height();

  $('.timeline').css({minHeight: docHeight});

  function get_tl_post() {

    if (loading==false) {

      loading = true;

      $.ajax({
        type:"POST",
        url:"timeline.php",
        data:"data=instagram",
        beforeSend:function(){
           $('.loader').fadeIn("slow");
        },
        complete:function(){
          loading = false;
          $('.loader').fadeOut("slow");
        },
        success:function(data) {
          if(data=="error")
          {
            get_tl_post();
          }
          $(data).hide().appendTo(".timeline").fadeIn(1000); 
        }
      });
    }
  }

  $(window).scroll(function(){
    if ($(window).scrollTop() == $(document).height() - $(window).height()) {
      get_tl_post();
    }
  });
});

This is Due to Network Mapping of your resources.这是由于您的资源的网络映射。

In other words, you might have added workspace folder in your chrome dev tools.换句话说,您可能在 chrome 开发工具中添加了工作区文件夹 Now when you are trying to make changes in some files it makes the Request to the File-System.现在,当您尝试对某些文件进行更改时,它会向文件系统发出请求。 This works fine for a while.这可以正常工作一段时间。 However in some scenarios you remove your network mapping.但是,在某些情况下,您会删除网络映射。

Then when you trying to open that web page on the browser, it might or might not ask for remapping of network resources and still try to update the File System.然后,当您尝试在浏览器上打开该网页时,它可能会或可能不会要求重新映射网络资源,但仍会尝试更新文件系统。 And that's when you get this error.这就是您收到此错误的时候。 There is nothing wrong with your script.你的脚本没有任何问题。

Now the only solution to this could be Removing cache, then restarting System.现在唯一的解决方案可能是删除缓存,然后重新启动系统。 If the problem still persist, you can simply re install chrome and this should be fixed.如果问题仍然存在,您只需重新安装 chrome 即可解决此问题。

Moreover, sometimes network mapping can cause several other issues as well.此外,有时网络映射也会导致其他几个问题。 For example, making the CSS file size to whooping 75MB or above.例如,使 CSS 文件大小达到 75MB 或以上。 So you have to take precautions when playing with network mapping.所以你在玩网络映射时必须采取预防措施。

Optionally if you are on Mac... or Even on Windows and have sh commands available.或者,如果您在 Mac 上...或者甚至在 Windows 上并且有可用的 sh 命令。

sudo find / -type f -size +50000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

Hit this in your Terminal to find out the culprit individual file which is over 50MB.在您的终端中点击此按钮以找出超过 50MB 的罪魁祸首个人文件。 you could then remove them.然后你可以删除它们。

Note : What the above command does it, it will find all the individual files which are more than 50MB and print them on your terminal one by one.注意:上面的命令是做什么的,它会找到所有超过 50MB 的单个文件,并将它们一一打印在您的终端上。

If I was to guess I would say your timeline.php script is always returning "error" so you are making too many calls recursively and the browser blocks them.如果我猜测我会说您的timeline.php脚本总是返回“错误”,因此您递归地进行了太多调用并且浏览器阻止了它们。

Try to eliminate the recursive function call and see if that will fix the problem.尝试消除递归函数调用,看看是否能解决问题。

Remove the following 3 lines and try again:删除以下 3 行并重试:

if (data == "error")
{
    get_tl_post();
}

If your ajax call fails for some reason, this could lead to too many recursive calls of the get_tl_post();如果您的 ajax 调用由于某种原因失败,这可能会导致get_tl_post();递归调用过多get_tl_post(); . .

I suggest that you use the error property for error handling, and to avoid situations of recursively calling your function.我建议您使用error属性进行错误处理,并避免递归调用您的函数的情况。 An idea could be to set a policy like "if the request failed/data are with errors, wait for an amount of time, then retry. If X retries are made, then show an error code and stop requesting".一个想法可能是设置一个策略,例如“如果请求失败/数据有错误,请等待一段时间,然后重试。如果进行了 X 次重试,则显示错误代码并停止请求”。

Below is an example of untested code, in order to show you the idea:下面是一个未经测试的代码示例,以向您展示这个想法:

var attempts = 0;
$.ajax({
  //Rest of properties
  success: function(data) {

    if(data == "error") {
      if(attempts < 3) {
        setTimeout(function(){
          get_tl_post();
          ++attempts;
        }, 2000);
      } else {
        //output failure here.
      }

    }

    //Rest of code....
  }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM