I’m working on a WordPress plugin and I need to make a query to the DB using AJAX.
My function looks like this:
function kokoku() {
if ($(".kokoku_head").height() === 0) {
$.ajax({
url: 'location_query.php',
success: function(data) {
$(".kokoku_head_bup").html(data);
}
});
}
};
Now in my location_query.php if I go for something static, like:
Echo “hey!”;
Return
Everything goes well. However the minute I add WP_Query()
I get a No 'Access-Control-Allow-Origin' header is present on the requested resource.
Error.
I have tried adding
header('Access-Control-Allow-Origin: *');
to the location_query.php file but the problem still persists.
My best guess is WP_Query()
is calling yet another file which is is returning the No 'Access-Control-Allow-Origin'
error and were I should add the header('Access-Control-Allow-Origin: *');
too, but I don’t know which file that might be.