$.getJSON not working with local JSON file

前端 未结 8 1095
野趣味
野趣味 2021-01-15 08:56

I am desperately trying to get a local build of a site to get a JSON file (also local) with no luck. The exact code worked perfect on my server, but once local, breaks.

8条回答
  •  情话喂你
    2021-01-15 09:26

    JSON has to load over the HTTP protocol rather than the local file protocol.

    The cross domain complaint is that it'll treat each file as a different domain so you need to run it in a web server.

    either set up a local webserver or store your JSON in a variable instead and skip getJSON altogether.

提交回复
热议问题