arun
arun

Reputation: 319

Use $.getJson To read Json File From LocalDrive

I have a JSON file on my C: drive. How can I read from it using the $.getJson function?

For example:

function getDisplay() {
    var url = 'C:\Dsecure\D7-1.Json';
    alert(url + "," + "Hell");
    $.getJSON(url).done(function (data) {
        //Do something
    });
}

Upvotes: 1

Views: 531

Answers (1)

Rory McCrossan
Rory McCrossan

Reputation: 337627

You can't make an AJAX request to the local file system as it will be blocked by most browsers security. You need to place your D7-1.Json file on an accessible webserver.

Assuming you're using Windows, you could set up IIS on your local machine and point the request at localhost for testing.

Upvotes: 3

Related Questions