$.getJSON not working with local JSON file

前端 未结 8 1169
野趣味
野趣味 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条回答
  •  旧时难觅i
    2021-01-15 09:27

    You should use http://localhost over file://localhost;

    $.getJSON(
     "http://localhost/Users/blakestruhs/new/lib/js/app.json",
         function(data){
            $.each(data, function(i,user){
            +'
            });
          }
    );
    

提交回复
热议问题