我已经通过响应访问数组元素
功能
function getUserList() {
$.ajax({
url: "https://reqres.in/api/users",
type: "POST",
data: {
name: "paul rudd",
movies: ["I Love You Man", "Role Models"]
},
success: function(response){
console.log(response); // prints the object
}
});
}
我的问题是电影阵列如何返回以下JSON对象在JavaScript中访问?我无法通过响应访问它 - 如果我确实得到“未定义”,则返回。
即response.movies
未定义
或response.movies [0]
未捕获typerror不能读取属性[0]的未定义
我得到在这两种情况下 – java
答案编辑不确定的,检查出来 – mattias
感谢..... +1 – java