The below data is returned as json
value. Please help me how to get the value or data in jquery ajax
.
{"detail":
{ "ID":001,
"Email":"test@test.com",
"Tel":"123-456-789",
"FirstName":"John",
"MiddleName":null,
"LastName":"Abraham",
"Prefix":null,
"Suffix":null,
"Street":"123 Mew Street",
"City":"New York",
"Region":"NY",
"Country":"USA",
"PostCode":"1011",
"Latitude":null,
"Longitude":null,
"valid":1,
"message":"success"
}
I have tried like below coding please advise me to update the code.
$.ajax({
type: "GET",
url: url,
dataType : 'json',
async: false,
success : function(text) { response = text; }
});
alert(response);
To access ID, you can use below code:
response.detail.ID
Similarly, access other fields
You can access JSON data by referencing the keys. For e.g.
success : function(text) {
response = text;
var id = response.detail.ID;
var email = response.detail.Email;
// AND Other properties........
}
try something like this
$.getJSON( url, function( response ) {
response.detail.ID //001
});