1

I'm trying to do an ajax call on a static teams.json file:

{
    "employees": [
        { "firstName":"John" , "lastName":"Doe" }, 
        { "firstName":"Anna" , "lastName":"Smith" }, 
        { "firstName":"Peter" , "lastName":"Jones" }
    ]
}

Here is my exact AJAX call:

this.testData = function() {
    return $.ajax({
        type: "GET",
        url: "js/dummy-data/teams.json",
        dataType: "json",
        async: false,
        success: function(data) {
            console.log(data);
        }
    });
}

The problem is that when I call testData(), What I see in the network tab of my Chrome inspector tools is something called "OPTIONS" as opposed to "GET".

I also see an error which states "Origin null is not allowed by Access-Control-Allow-Origin" error...

All I want to do is return the json object and console.log it out. Where am I going wrong?

lorenzoid
  • 1,692
  • 10
  • 32
  • 50

0 Answers0