Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7955267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:40:34+00:00 2026-06-04T03:40:34+00:00

This is a simplified code. I have a webservice (.asmx) as following: I store

  • 0

This is a simplified code. I have a webservice (.asmx) as following:
I store some values in Test class and then store the class in an arraylist.
I do this two times in two different arraylists.
and then store these two array lists in a third arraylist.
and then pass this arraylist as output of webmethod.

 private class Test
        {
            public string Id;
            public string Name;
        }

[webmethod]

      public ArrayList RuleReport(long RuleId)
    {
        Test t = new Test();
        t.Id = "1";
        t.Name = "a";

        ArrayList ar = new ArrayList();
        ArrayList ar2 = new ArrayList();
        ArrayList ar3 = new ArrayList();

        ar.Add(t);

t = new Test();
        t.Id = "2";
        t.Name = "b";
        ar2.Add(t);
        ar3.Add(ar);
        ar3.Add(ar2);
        return ar3;
    }

and in js file I want to parse he json result to read each Id and Name values of two arraylists.

id=1,name=a
id=2,name=b

this is my jquery code:

 $.ajax(
{ url: " Ajaxes/Rules.asmx/RuleReport",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    type: "POST",
    data: "{'RuleId':'79'}",
    async: false,
    success: function(data) {
    $.each(data.d, function(index, obj) {
    alert(obj.d[0].Id);// something like this. How to do it???
        })

    }, error: function() { }
});

this is the json response in fire bug:

{"d":[[{"Id":"1","Name":"a"}],[{"Id":"2","Name":"b"}]]}

how to get every Id and Name values???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:40:35+00:00Added an answer on June 4, 2026 at 3:40 am

    With your current setup inside $.each loop you are getting

    [{"Id":"1","Name":"a"}]
    

    as obj. As you can see it’s a array of object with only one object as it’s content. You can access that object with obj[0] and then their properties can be accessed with obj[0].Id and obj[0].Name

    You can do this with the following code

    $.each(data.d,function(index,obj){
    
           var id = obj[0].Id;
           var name = obj[0].Name;
           // do what ever you want with them
       })​
    

    Working fiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simplified my code to this internal class Program { private static void
I have a class with a few simple structs like this (simplified code) inside
I have this simplified code: <div class=container> <input type=submit name=submit class=submit value=Sign Up> </div>
I have a following (simplified) code: var myModule = { submitDummyForm: function(){ console.log(this); //
I have the following (simplified) code periodically run by a Thread in the class
I have code like this (simplified): def outer(): ctr = 0 def inner(): ctr
I have this code (which is way simplified from the real code): public interface
I have this code and cannot figure out how it could be simplified via
I am customizing my table cells. I have this code (simplified) which is giving
Basically the situation is like this (simplified, pseudo code): I have 2 TABLES person

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.