Hello fellow campers!
I am trying to do a simple ajax request to retrieve a json file from the server and store it in a javascript object.
I have tried 2 different methods .ajax() method and .getJSON().
Both methods in the Network console seem to fetch the file with result HTTP/1.1 200 OK.
But when I tried to output the received data in the console with console.log(data) nothing shows up.
I have enabled the cross-origin requests in Firefox as I run my code locally and the web server is on a Rpi(Wordpress).
$.ajax({
url: 'http://192.168.0.227/json/sysC01.json',
dataType: 'json',
type: 'GET',
cache: false,
crossDomain: true,
success: function(data){
console.log(data);
},
});
$.getJSON("http://192.168.0.227/json/sysC01.json", function(result){
console.log(result);
});
I am logged in in the site of course. Maybe there is something in the server-side? I just stored the json files in a folder in the /var/www/html directory. If i request the json file from the url it shows as expected in the browser. I also temporarily disabled the antivirus in case it blocked the insecure communication.
As a first step I want to see that the data are received, which I can’t at the moment, and afterwards I would like to store the data in a Javascript object and output them inside a div element with a certain format.
Any suggestion is highly appreciated.