Loading local json into p5.JS

edited May 2015 in p5.js

I'm having trouble loading a local file or local image into p5.js. Keep getting the error: MLHttpRequest cannot load file:///Users/mac/Desktop/p5/empty-example/assets/test.txt.




  • Some browsers have limitations on loading files / running JS using the file:// protocol.
    You should start up a simple web server, like Mongoose, and run your code from http://localhost

  • Or just use Firefox Development Edition:

    No need for any server this way! \m/

  • perfect! works now! thanks.

  • edited August 2015

    can you update the local json file in p5js. I mean, can we update the local data.json file with new json object,

    For example let say I have -

        // data.json
            "id": 0
            "text":"New processing is avaialbe to download"
            "id": 1
            "text":"I am the new processing"
            "id": 2
            "text":"Now I am updated. Restart me"
        // New json object ---> how to update this in the file
            "id": 3
            "text":"I am the new JSONOBject hwo do I update my self"
  • A browser can read a file from the file system, but it won't write it back! Or you need a server-side code (PHP or other) to get the update request and modify the file accordingly.

Sign In or Register to comment.