我使用post方法得到了Json,
$.post('urlhere',function (data) {
alert(data.Experience)
});
如果我试图从JSON响应中获取一个元素,如alert(data.Experience).但它将显示“Undefined”.如何从以下Json获取特定节点?
获得响应,如,
[
{
"Name": null,"EmployeeId": 0,"Email": null,"UserName": null,"Password": null,"JobTitle": null,"JobID": null,"Skillsrequired": "Struct","Experience": "2","Description": null,"listval": null,"Status": null,"JobLocation": null,"JobPostedDate": "/Date(-62135596800000)/","AssignJobID": null,"AssignJobTitle": null,"AssignJobHr": null,"AssignDateofInterview": "/Date(-62135596800000)/","AssignDescription": null
}
]
最佳答案
首先确保您接收的JSON是json或字符串的解析形式,如果它是一个字符串,则在从JSON.parse(data)访问它之前解析它.第二件事是您收到的数据是一种数组,因此您必须指定索引来访问其中的值,这意味着JSON.
原文链接:https://www.f2er.com/jquery/428756.html尝试,
alert(data[0].Experience);