doufei1852 2018-09-05 08:37
浏览 125

在Wordpress wp-json的预检响应中,Access-Control-Allow-Header不允许使用X-Requested-With

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 有赏,i卡绘世画不出
    • ¥15 如何用stata画出文献中常见的安慰剂检验图
    • ¥15 c语言链表结构体数据插入
    • ¥40 使用MATLAB解答线性代数问题
    • ¥15 COCOS的问题COCOS的问题
    • ¥15 FPGA-SRIO初始化失败
    • ¥15 MapReduce实现倒排索引失败
    • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
    • ¥15 找一位技术过硬的游戏pj程序员
    • ¥15 matlab生成电测深三层曲线模型代码