Javascript - ERR_CONTENT_LENGTH_MISMATCH [英] Javascript - ERR_CONTENT_LENGTH_MISMATCH

查看:1137
本文介绍了Javascript - ERR_CONTENT_LENGTH_MISMATCH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个基本的jquery游乐场网站。我收到错误: net :: ERR_CONTENT_LENGTH_MISMATCH 正在页面加载中发生,并且背景图片未加载到页面上。



有问题的图像是300kb,并且也在动态变化。我假设这与文件大小有关,但我真的不知道该怎么做。原本使用的HTML:

 < p style =margin:0px; padding:0px;> 
< img id =backgroundsrc =/ bg1.jpgstyle ='width:100%;'border =0alt =Null>
< / p>

javascript / jquery用于更改背景:

  var changebg = function(){
if(myscore%20 == 0){
level ++;
document.getElementById(level)。innerHTML =Level:+ level;
$(#level)。fadeIn(1500,function(){$(#level)。hide()})
backgroundindex ++;
if(backgroundindex> 6){
backgroundindex == Math.floor((Math.random()* 6)+1)};
document.getElementById(background)。src =/ bg+ backgroundindex +。jpg;
};
}


解决方案


我收到错误:net :: ERR_CONTENT_LENGTH_MISMATCH


查看您的服务器日志以确定真正的问题是什么。



对于我来说,问题在于nginx和文件权限之间:


  • tail -f /usr/local/var/log/nginx/error.log 或运行 nginx -t
  • 刷新浏览器中的资产,例如 http:// localhost:3000 / assets / jquery / jquery.js



您可能在日志中看到类似这样的内容:


失败(13:
权限被拒绝)同时阅读上游文件xyz


继承人我如何修正:

  sudo nginx -s stop 
sudo rm -rf / usr / local / var / run / nginx / *
sudo nginx


I'm making a basic jquery playground site. I am getting Error: net::ERR_CONTENT_LENGTH_MISMATCH is happening on page load and the background images are not loading on the page.

The image in question is 300kb and is also dynamically changing. I am assuming this has something to do with file sizes, but I dont really know what.

HTML used originally:

<p style="margin:0px; padding:0px;">
  <img id="background" src="/bg1.jpg" style='width:100%;' border="0" alt="Null">
</p>

javascript / jquery used to change the background:

var changebg = function() {
  if (myscore % 20 == 0) {
    level++;
    document.getElementById("level").innerHTML = "Level: " + level;
    $("#level").fadeIn(1500, function(){$("#level").hide()})
    backgroundindex++;
    if (backgroundindex > 6) {
      backgroundindex == Math.floor((Math.random()*6)+1)};
    document.getElementById("background").src="/bg"+backgroundindex+".jpg";
  };
}

解决方案

I am getting Error: net::ERR_CONTENT_LENGTH_MISMATCH

Have a look at your server logs to determine what the real issue is.

For me the problem lay somewhere between nginx and file permissions:

  • tail -f /usr/local/var/log/nginx/error.log or run nginx -t to determine your conf location, where you could specify a custom log path.
  • refresh the asset in your browser, eg http://localhost:3000/assets/jquery/jquery.js

You may see something like this in the logs:

"/usr/local/var/run/nginx/proxy_temp/9/04/0000000049" failed (13: Permission denied) while reading upstream for file xyz

Heres how I fixed:

sudo nginx -s stop    
sudo rm -rf /usr/local/var/run/nginx/*    
sudo nginx

这篇关于Javascript - ERR_CONTENT_LENGTH_MISMATCH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆