Problem Getting Json file from wordpress server with Jquery getJson or ajax method

Problem Getting Json file from wordpress server with Jquery getJson or ajax method
0.0 0


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).

			url: '',
			dataType: 'json',
			type: 'GET',
			cache: false,
			crossDomain: true,
			success: function(data){

$.getJSON("", function(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.


The only times I have done similar to this I have used the file system to read the file.
For example:

function readTextFile(file) {
    var rawFile = new XMLHttpRequest();
    var allText = ''"GET", file, false);
    rawFile.onreadystatechange = function ()
        if(rawFile.readyState === 4)
            if(rawFile.status === 200 || rawFile.status == 0)
                allText = rawFile.responseText;
    // var allText = rawFile.responseText;
    return allText;

I also did a similar thing with a node project:


Dear JohnnyBizzel,

Thanks a lot for your reply.
After trying a lot of different things, this was the one that worked:

I started chrome with web security disabled(it was not a Jquery issue).

chrome.exe --user-data-dir=“C:/Chrome dev session” --disable-web-security