I have a Wordpress blog site installed in a sub folder in my root directory and a static single page site hosted in the same root directory. Now I am trying to get the blogs in my static site by JQuery AJAX calls from wp-json rest api. But the server is responding with the following error message:
Failed to load https://example.com/rest/of/url: Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers in preflight response.
I have installed a plugin to add the Headers in my WP blog site but its also not working. I am adding my JS code here as well.
$.ajax({
url : 'https://example.com/rest/of/url',
method: 'GET',
dataType: 'json',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
Can somebody help me with this issue.