UserRA
UserRA

Reputation: 185

display data using Ajax

I want to display data in the value field of dictionary using Ajax. I know the format to display, but stuck in displaying one of the fields. Code is here :

$.each(result, function(index, element) {
      alert(element.Place);
      alert(element.Unique Name);
   });

element.Unique Name doesn't work as there is a space in between( It is Unique Name not UniqueName). Could you guys help me out displaying this?

Upvotes: 0

Views: 104

Answers (1)

Abhishek
Abhishek

Reputation: 462

Fiddle for your answer

    var data = {
    "employees": [{
        "firstName": "John",
        "Unique Name": "Doe"
    }, {
        "firstName": "Anna",
        "Unique Name": "Smith"
    }, {
        "firstName": "Peter",
        "Unique Name": "Jones"
    }]
};

$.each(data, function (index, element) {
    alert(index);
    $.each(element, function (inde, data1) {
        alert(inde);
        alert(data1.firstName);
        alert(data1['Unique Name']);
    });
});

I think it may meet your requirements. plz let me know if works.

Upvotes: 1

Related Questions