Javascript:远程服务器上出现Three.js JSON错误,但本地服务器上没有 [英] Javascript: Three.js JSON error on remote server, but not on local

查看:179
本文介绍了Javascript:远程服务器上出现Three.js JSON错误,但本地服务器上没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写Three.js应用程序.在其中的一部分中,我使用

I'm writing a Three.js application. In part of it, I load a blender model exported as a JSON file using the Blender->JSON exporter for Three.js. I have WAMPServer 2.2 configured on my local computer (Windows 7) that I use to test my website before I FTP it to the remote server to show off to friends and such.

加载此JSON文件在本地测试服务器上工作正常,但是当我将其上传到服务器时,在Firebug,Firefox 16.0.2中出现以下错误:

Loading this JSON file works fine on the local test server, but when I upload it to the server, I get the following error in Firebug, Firefox 16.0.2:

SyntaxError: JSON.parse: unexpected character
  var json = JSON.parse( xhr.responseText );
  three.js (line 7810)

发现JSON文件很好-GET显示在Firebug中.据我所知,模型的加载是整个脚本中唯一的JSON加载.该模型也不会远程显示,而是在本地显示.这是其中包含负载的函数:

It's finding the JSON file fine - the GET shows up in Firebug. The loading of the model is, as far as I can tell, the only loading of JSON I have in the entire script; the model also doesn't show up remotely, where it does locally. Here's the function with the load in it:

//Adds a unit to the scene. Assumes Init() hasn't been called on the unit yet.
function pubAddUnit(unit, coord, modelSrc)
{
    //Do whatever initialization the unit has to do
    unit.Init();

    //Store the unit in its position on the grid
    units[coord.y][coord.x] = unit;

    //Load the unit model
    var loader = new THREE.JSONLoader();
    loader.load(modelSrc,
            //Function called once the unit model is loaded
            function(geometry) {
                //Create a new material for the unit
                var material = new THREE.MeshFaceMaterial();
                var mesh = new THREE.Mesh(geometry, material);
                //Store the unit geometry and mesh into their respective grids
                unit.SetGeo(geometry);
                unit.SetMesh(mesh);

                //Move the mesh to the correct spot
                mesh.position = TransCoord2(coord);
                mesh.scale.set(40, 40, 40);

                //Add the mesh to the scene
                scene.add(mesh);

                //Update the scene, now with the mesh in
                update();
            });
}

这是JavaScript文件,如远程服务器上所示.对此原因的任何想法都值得赞赏.

And here's the javascript file, as showing on the remote server. Any ideas on why this is happening is appreciated.

我正在使用FileZilla到FTP.我确实突然注意到服务器上JSON文件的文件大小与本地文件的文件大小不同,但是我不确定这是否是我需要担心的事情-也许是行尾或其他内容?

I'm using FileZilla to FTP. I did suddenly notice that the filesize of the JSON file on the server differs from that of the local, but I'm not sure if that's something I need to worry about or not - perhaps it's line endings or something?

此外,这是JSON文件.

推荐答案

好,所以我想出了问题" ...事实证明该文件根本没有得到JSON文件,而只是一个响应,说被黑客入侵"-我只是没有足够仔细地查看GET响应.我认为该网站上的所有GET都将重定向到该文件被黑客入侵".显然,这不在此问题的范围内,但是如果任何人有任何可以帮助您的信息,请告诉我.

Ok, so I figured out the "problem"... Turns out the file isn't getting the JSON file at all, but simply a response that says "hacked by hacker" - I just didn't look at the GET response closely enough. I think all GETs from the site are being redirected to this file, "hacked by hacker." Obviously, this is outside of the scope of this question, but if anyone has any info that could help, please let me know.

这篇关于Javascript:远程服务器上出现Three.js JSON错误,但本地服务器上没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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