Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined value in JSON

I get the Json by using the post Method,

                    $.post('urlhere', function (data) {
                        alert(data.Experience)
                    });

If I trying to get one element from the JSON Response like alert(data.Experience).But It will show "Undefined".How to get the particular node from the following Json?

Get the Response like,

[
    {
        "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
    }
]
like image 446
V.V Avatar asked Jun 11 '14 04:06

V.V


People also ask

Can undefined be a JSON value?

JSON values cannot be one of the following data types: a function. a date. undefined.

Why does JSON show undefined value?

If it's a JSON, it's a string, so it doesn't have that property. You are trying to use it as an object (the O in JSON). Save this answer.

Which is an invalid JSON value?

It means that the editor failed to get a response to the server or the response wasn't in a valid JSON format. Basically, if the editor can't communicate with the server, it will show this error message instead. To fix the problem, you essentially need to fix whatever is getting in the way of the communication.


2 Answers

First make sure that the JSON that you are receiving is a parsed form of json or a string, If it is a string parse it before accessing values from it like JSON.parse(data). And the second thing is the data that you are receiving is a kind of array, so you must need to specify the index to access the values inside it meaning the JSON.

Try,

alert(data[0].Experience);
like image 101
Rajaprabhu Aravindasamy Avatar answered Sep 18 '22 09:09

Rajaprabhu Aravindasamy


Try with

JSON Array 0th Object Has Experience.SO Acces Like Below

alert(data[0].Experience)

DEMO

like image 24
Sridhar R Avatar answered Sep 20 '22 09:09

Sridhar R