[英]Cant reading json variables trough rest api
我在通過REST API讀取變量JSON時遇到問題
問題:
我的傑森
.....
“ Featured_media”:11661,
“ Comment_status”,“打開”
“ Ping_status”,“打開”
“ Geolocation_city”:[“ Oeiras”],
“ _links”:{
“自我”:[{
“ Href”:“ http:\\ / \\ / website.com \\ / wp-json \\ / wp \\ / v2 \\ / Listings \\ / 11660”
.....
我可以用這段代碼少讀所有的geolocation_city變量
$.getJSON('http://imaginocharme.com/wp-json/wp/v2/listings/11660', function (jd) {
$('#stage').html('<p> Nome: ' + jd.featured_media + '</p>');
console.log(jd.featured_media);
$('#stage').append('<p>Descrição : ' + jd.comment_status + '</p>');
console.log(jd.comment_status);
$('#stage').append('<p>Nome : ' + jd.ping_status + '</p>');
console.log(jd.ping_status);
$('#stage').append('<p>Cidade : ' + jd.geolocation_city + '</p>');
console.log(jd.geolocation_city);
$('#stage').append('<p>Links : ' + jd._links.self[0].href + '</p>');
console.log(jd._links.self[0].href);
});
我的控制台日志
11661
index.html (29,29)
open
index.html (31,29)
open
index.html (33,29)
undefined
index.html (35,29)
http://imaginocharme.com/wp-json/wp/v2/listings/11660
index.html (37,29)
我已經嘗試了幾種讀取變量geolocation_city的方法,並且總是給出未定義的
有人可以幫忙嗎?
任何想法?
jd.geolocation_city是一個數組,這就是為什么您不顯示它的原因。 嘗試以下方法:
jd.geolocation_city.toString()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.