0

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);
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149

3 Answers3

0

To access ID, you can use below code:

response.detail.ID

Similarly, access other fields

Rajesh
  • 3,743
  • 1
  • 24
  • 31
0

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........
 }
Gurminder Singh
  • 1,755
  • 16
  • 19
0

try something like this

   $.getJSON( url, function( response ) {
       response.detail.ID  //001
    });
rajesh kakawat
  • 10,826
  • 1
  • 21
  • 40