0

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.

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)

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();
            });
}

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


EDIT: 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?


Also, here is the JSON file.

Chaosed0
  • 949
  • 1
  • 10
  • 20
  • Use one of number json validators, like http://jsonlint.com/ – zerkms Nov 19 '12 at 03:50
  • @zerkms I've done that, and it passes validation fine (both the local version and the remote version I downloaded from the server, again using FileZilla). – Chaosed0 Nov 19 '12 at 03:52
  • so parser says it's broken, we don't see it currently. What kind of help are you expecting then? – zerkms Nov 19 '12 at 03:53
  • @zerkms Huh? I'm not sure what you mean. I can view it in my browser just fine. Do you mean you can't load the script on the page? – Chaosed0 Nov 19 '12 at 03:55
  • nono, when I added my comment I didn't see the link to a json file – zerkms Nov 19 '12 at 03:55
  • Well, stripe all the newlines and everything will be parsed fine – zerkms Nov 19 '12 at 03:56
  • @zerkms Oh alright, I just decided to add it since you put in that comment, sorry about that. EDIT: Let me try removing the newlines. – Chaosed0 Nov 19 '12 at 03:57
  • @zerkms Removing the newlines did not help, though it did make the filesizes the same across the local and remote machines. – Chaosed0 Nov 19 '12 at 04:01
  • for me it helped. Just opened console and tried with and without newlines. The latter worked fine (see https://dl.dropbox.com/u/4486681/parse.png) – zerkms Nov 19 '12 at 04:02
  • @zerkms Strange, can you paste the exact code you used? I even removed all whitespace and it still is giving me the same error. EDIT: Whoop, there it is, trying now... – Chaosed0 Nov 19 '12 at 04:04
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/19735/discussion-between-chaosed0-and-zerkms) – Chaosed0 Nov 19 '12 at 04:14

1 Answers1

0

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.

Chaosed0
  • 949
  • 1
  • 10
  • 20