0

I'm a newbie learning JavaScript (specifically Leaflet.js for making maps), and I've run into a problem when trying to load data stored as JSON from a file on my Weebly site. The code I've used is:

    var test = "http://www.kingcountydata.weebly.com/files/theme/hrabasetopo.json?jsoncallback=?";
    $.getJSON(test, function (json) {
        console.log(json);
        console.log("success");
    });

This seems like it should work, but neither the JSON data nor "success" show up in my browser console. Am I missing something obvious here? Thank you in advance for your help!

Eli Kern
  • 319
  • 1
  • 3
  • 12

1 Answers1

0

You can achieve it by using $.ajax() function like following and also debug the error:

  $.ajax({
    contentType: 'application/json',
    dataType: "json",
    url: "http://www.kingcountydata.weebly.com/files/theme/hrabasetopo.json?jsoncallback=?",
    success: function (dataCheck) {
                    console.log(dataCheck); 
                },
    error: function(data, errorThrown)
          {
              alert('request failed :'+errorThrown);
          }

    });
Kapil Kshirsagar
  • 282
  • 1
  • 4
  • 19