我有一个WordPress站点,它有一个叫做JSON API的插件.这个插件为WordPress中的内容提供了JSON格式.我可以通过在php头上添加Header("Access-Control-Allow-Origin:*");在WordPress上启用CORS.但是,当我try JSON API插件提供的url时,CORS不再起作用.

This is the wordpress site were I'm doing the tests... I used the test cors website to check if it was working and it is... http://kiwa-app.loading.net/

但是,当我try 使用JSON api提供的url时,它已经不起作用了.我仍然有错误没有"访问控制允许起源"

I will apreciate some help thanks!!!

推荐答案

好的,我终于想出了一个简单的办法……

You just have to add:

     <? header("Access-Control-Allow-Origin: *"); ?>

On the file api.php, this file is located in wp-content/plugins/json-api/singletons/api.php

I hope it helps more people with the same problem!

Json相关问答推荐

JOLT拉平数组

Vega-Lite:文本笔画在外部

Jolt将键和值转换为单独的数组集

SWIFT中的网络经理

Oracle plsql:如何将json文件加载到嵌套表中

使用jq过滤复杂json对象中的数据

当 JSON 字段名称有空格时,ABAP 中的 JSON 反序列化

使用 Powershell,如何将 Azure AD 组成员转换为 Json 对象(文件),然后可以更新?

JOLT转换并向输出添加新数组

如何使用 JOLT 将带有列表的 JSON 项目取消列出为多个项目?

Shell脚本空格转义

shell解析json并循环输出组合变量

如何在 jQuery 中循环遍历 JSON 数组?

Swift:如何从字典中删除空值?

IE中Json响应下载(7~10)

在 JSON.stringify() 的输出中隐藏空值

jquery用json数据填充下拉列表

错误未判断调用put(K, V)作为原始类型java.util.HashMap的成员

使用杰克逊创建一个 json 对象

在android中读取Json数组