When I build for HTML 5 and try and run it via my website I get the following error:
An error occured running the Unity content on this page. See your browser JavaScript console for more info. The error was:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
The build runs perfectly fine locally via Firefox.
I had a similar situation previously which was fixed by adding a 3rd-party web.config file to the project folder. Is that what is needed now?
So, it appears that the problem is that Windows servers will not read a JSON file. I did some googling regarding Windows servers and JSON files and apparently Windows servers will not recognise a JSON file unless it’s identified in a web.config.
I added the following line to my existing web.config (from Unity 5.5.0):
Success! It got past the JSON problem but then threw up another error - the details of which I forget. It occured to me that as 5.6 now uses .unityweb that that might need identifying as well. I added the following line to the web.config guessing that unityweb files were binary.
IT WORKS!
The final working web.config for Unity 5.6 looks like this:
I dropped the web.config in the Build folder and ran it through Firefox from the server and it works fine.
I can probably get rid of the Unity 5.x and 5.3 lines now but I’ll leave them there for the time being to be on the safe side.
I appreciate that to web programmers this is probably child’s play but I’m way out of my depth here so I struggle to figure this stuff out.
I hope that helps a lot of folks. There are certainly a lot following this thread.
Also, thanks for all your help Unity. You were awesome
We ran into this problem and none of the previous fixes applied to our environment. We fixed the issue by changing our custom WebGLTemplate’s index.html from:
var gameInstance = UnityLoader.instantiate("gameContainer", "Build/MyGame.json", {
to
var gameInstance = UnityLoader.instantiate("gameContainer", "%UNITY_WEBGL_BUILD_URL%", {
I still don’t have a solution for this project stopping bug yet. I really can’t see the issue. It’s really not happy with the { at the start of the file. That’s definitely the first character in the file. Line 1, column 1 (I even checked for hidden characters in a hex editor) and that’s apparently what’s supposed to be there in a JSON file and yet, the reader just won’t accept it.
Hi, I’m getting the exact same problem when exporting the Space Shooter project to html5. Works fine on my local machine but when I upload it to my web hosting I get the above error.
@Wayne_Peters I had this issue in version 2017.1.1f1 and I was creating a site to host this HTML5 output and all I need to do was add <mimeMap fileExtension=".unityweb" mimeType="application/octet-stream"/> to my web.config and it worked!
I had the same error when I build for WebGL, and your solution works.
Thank you very much for sharing your knowledge, it has been a great help to me since I am an amateur programmer.
Regards