Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.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
Javascript axios获取的数据在div中显示为[undefined,undefined]_Javascript_Jquery_Json_Get_Axios - Fatal编程技术网

Javascript axios获取的数据在div中显示为[undefined,undefined]

Javascript axios获取的数据在div中显示为[undefined,undefined],javascript,jquery,json,get,axios,Javascript,Jquery,Json,Get,Axios,我试图在浏览器中呈现url的JSON数据,但它在div中显示为未定义、未定义。当我把它的响应放在console.log中时,对象和它的数据就会出现,因此在控制台和浏览器中出现的对象和数据之间会有某种程度的断开。我已经获得了其他rest调用显示的其余数据,但在解决此问题之前,我将无法看到它们并继续我的项目 有什么想法吗?一段时间以来,我一直在努力获取这些数据,这一直困扰着我 PS-不确定它是否有帮助,但我使用IE11与这一个不是我想,但我在这件事上没有什么发言权 index.js: office.

我试图在浏览器中呈现url的JSON数据,但它在div中显示为未定义、未定义。当我把它的响应放在console.log中时,对象和它的数据就会出现,因此在控制台和浏览器中出现的对象和数据之间会有某种程度的断开。我已经获得了其他rest调用显示的其余数据,但在解决此问题之前,我将无法看到它们并继续我的项目

有什么想法吗?一段时间以来,我一直在努力获取这些数据,这一直困扰着我

PS-不确定它是否有帮助,但我使用IE11与这一个不是我想,但我在这件事上没有什么发言权

index.js: office.js: 办公数据JSON:
看起来结果是一个数组,因此您必须通过以下方式访问它:

response[0].office_number


哇,我想答案要复杂得多。我使用mattsComponent作为指导,但没有意识到它实际上与我试图使用officeComponent实现的目标不同。非常感谢。
import $ from 'jquery';
// ------------------- //
console.log("office.js working")
export default class {
    constructor() {

    }

    loadOfficeData(response) {
        $("#seat-val").append(response.office_number + ", " + response.floormap);  
    }   
}
{
  "d": {
    "results": [
      {
        "floormap": "[location here]",
        "floormapid": 10,
        "resourcelocation": "[redacted]",
        "office": "[location here]",
        "officeid": 3,
        "office_number": "00-605"
      }
    ]
  }
}
response[0].office_number
response[0].floormap