【发布时间】:2015-10-09 19:33:48
【问题描述】:
我必须设法使用 API 显示我的帖子,我遇到了格式错误的 json 的问题,因为内容部分中的一些 html 返回了 API。
jQuery ajax:
$.ajax({
cache: false,
type: "GET",
dataType: "json",
url: "http://bytto.com/wp-json/posts?type[name]=package&filter[category]=eco-tours-petate",
success: function(data){
}
});
要查看 json,只需将下一个 url 复制并粘贴到 chrome 或 firefox 中:
http://bytto.com/wp-json/posts?type[name]=package&filter[category]=eco-tours-petate
我评估了http://jsonformatter.curiousconcept.com/ 的回复并说:
Error:Invalid characters found.
我看了一下,它在内容节点和摘录节点上 json 失败。
如果我将其作为纯文本返回:dataType: "text" 它来了,我喜欢做的是清理文本以使其成为 json。
【问题讨论】:
-
你能分享你的 JSON 吗?
-
当然,只需将此网址复制并粘贴到 chrome 或 firefox 中:bytto.com/wp-json/…
标签: jquery ajax json wordpress api