KolaCaine
KolaCaine

Reputation: 2187

Can't display JSON with AJAX

I have a JSON file, with many data inside. And I want to display this with AJAX, so I tried to make this but doesn't work and after much search on internet I call your help :

    $(document).ready(function () {
        $.getJSON("data/liste_des_sites_des_hotspots_paris_wifi.json").done(function(){

            function donnee (data) {
                console.log(data)
            }


    })

Upvotes: 0

Views: 76

Answers (3)

Ouroborus
Ouroborus

Reputation: 16865

AJAX doesn't work well with the file:// protocol (loading files directly from your file system). Access the page and files from a web server (localhost or otherwise).

Upvotes: 1

bhansa
bhansa

Reputation: 7504

Sample getJSON example

$(document).ready(function () {
        $.getJSON("https://gist.githubusercontent.com/moredip/4165313/raw/ad00ee5bc70016a70976736d5cdf0463d5f7ea15/test.json",function(data){
       console.log(data); 
        });
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

Upvotes: 0

mehulmpt
mehulmpt

Reputation: 16547

 $(document).ready(function () {
        $.getJSON("yourlocation").done(function(){

            console.log(data);


    });
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Your syntax is bad/wrong.

Upvotes: 1

Related Questions