Jump to content

how to load json files.


madhurhtml5
 Share

Recommended Posts

Hi,

i am trying the example of p2 physics i.e contact event . As i have develop complete game where i am loading all the game image and json file in loading screen. It load only image  and giving error for json file    . Error in console is :

  1. Uncaught SyntaxError: Unexpected token <

 

I have provided correct path of json file and also running the file on localhost .

Secondly , the syntax i have use for loading the json file is:

 

game.load.physics('physicsData','assests/physics/sprites.json'); 

 

plz help me out ...

 

 

Link to comment
Share on other sites

  • 2 weeks later...

I am having the exact same symptoms, although I am loading the JSON file via load.atlas.

 

The odd thing is, in WAMP on my local machine, my code runs fine.  Only when I put my code on an external server (it uses IIS 8), do I experience the problem.  I did try forcing the JSON file format to PC UTF-8.

Link to comment
Share on other sites

Have you tried explicitly telling the webserver to host .json files? They don't host them by default. My web.config has this addition: 

  <system.webServer>    <staticContent>      <mimeMap fileExtension=".json" mimeType="application/json"/>    </staticContent>  </system.webServer>
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...