Software Archive
Read-only legacy content
17061 Discussions

I couldn't get local json file with jquery.getJSON method

Fatih_Mert_D_
Beginner
1,689 Views

Hi guys,

My json file is 'www/js/test.json' so it is same folder with app.js

My codes in app.js simple get json method my code bellow;

 

window.kelDb = "";

$.getJSON('test.json',function(jData){
    window.kelDb = jData;
});

var kDb = window.kelDb;
alert(kDb.simple.tree);

How can I do access in www folder any file type ?

Thank you for interest.

Good works..

0 Kudos
3 Replies
Elroy_A_Intel
Employee
1,689 Views

The method that you are using is intended to load JSON-encoded data from a server using a GET HTTP request as stated here. You are not able to load local file with that method. By design, standard JavaScript is not allowed to access or operate on a file. 

0 Kudos
Fatih_Mert_D_
Beginner
1,689 Views

How can I load local json file to associated javascript varriable ? Is this possible ?

Thank you.

0 Kudos
PaulF_IntelCorp
Employee
1,689 Views

You'll need to use the File plugin to access the file. See the Cordova core plugins in the plugin manager on the projects tab.

0 Kudos
Reply