如何使用外部API从wordpress外部提取数据?
我需要从外部API中提取数据,但不确定如何实现。。我尝试了下面的方法,它的工作,但在点击按钮,我需要调用另一个api,同样需要显示在新的页面和im卡住如何使用外部API从wordpress外部提取数据?,wordpress,Wordpress,我需要从外部API中提取数据,但不确定如何实现。。我尝试了下面的方法,它的工作,但在点击按钮,我需要调用另一个api,同样需要显示在新的页面和im卡住 <script> var obj, dbParam, xmlhttp, myObj, x, txt = ""; obj = { "limit":10 }; dbParam = JSON.stringify(obj); xmlhttp = new XMLHttpRequest(); xmlh
<script>
var obj, dbParam, xmlhttp, myObj, x, txt = "";
obj = { "limit":10 };
dbParam = JSON.stringify(obj);
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myObj = JSON.parse(this.responseText);
for (x in myObj.jobs) {
var joblink = "https://boards-api.greenhouse.io/v1/boards" + myObj.jobs[x].id;
txt += "<div class='col-md-12'>" +
"<span class='title'>" +
myObj.jobs[x].title +
"</span>"+
"</br>" +
myObj.jobs[x].location.name + "</br>" +
"<form method='post' action='sample.php' >" +
"<a href=" + joblink + ">" +
"<button type='submit' class='btn'>Refer</button>" + "</a>" +
"</form>"+
"</div>"
;
}
document.getElementById("demo").innerHTML = txt;
}
};
xmlhttp.open("GET", "https://boards-api.greenhouse.io/v1/boards", true);
xmlhttp.send();
</script>
var obj,dbParam,xmlhttp,myObj,x,txt=“”;
obj={“限制”:10};
dbParam=JSON.stringify(obj);
xmlhttp=新的XMLHttpRequest();
xmlhttp.onreadystatechange=函数(){
if(this.readyState==4&&this.status==200){
myObj=JSON.parse(this.responseText);
对于(myObj.jobs中的x){
var joblink=”https://boards-api.greenhouse.io/v1/boards“+myObj.jobs[x].id;
txt+=“”+
"" +
myObj.jobs[x].标题+
""+
“”+
myObj.jobs[x].location.name+“”+
"" +
"" +
""+
""
;
}
document.getElementById(“demo”).innerHTML=txt;
}
};
open(“GET”https://boards-api.greenhouse.io/v1/boards“,对);
xmlhttp.send();