Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用外部API从wordpress外部提取数据?_Wordpress - Fatal编程技术网

如何使用外部API从wordpress外部提取数据?

如何使用外部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

我需要从外部API中提取数据,但不确定如何实现。。我尝试了下面的方法,它的工作,但在点击按钮,我需要调用另一个api,同样需要显示在新的页面和im卡住

<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();