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

  • Home
  • SEARCH
  • 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 7007907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:40:04+00:00 2026-05-27T21:40:04+00:00

Based on the following code… A user can come along and add as many

  • 0

Based on the following code…

A user can come along and add as many ‘outgoings’ as they like via a separate function. I then add a new ‘li’ to the DOM and auto generate the txt ID

<ul id="ulOutgoing">    
    <li>
        <label>Outgoing 1</label><input type="text" id="txtOutGoing0">
    </li>
    <li>
        <label>Outgoing 2</label><input type="text" id="txtOutGoing1">
    </li>
</ul>    

At the end of the users path i need to send all txt values and labels to the server to firstly save to a db then generate a response based on the supplied data.

var OutGoings = {};

$('#ulOutgoing').find('li').each(function () {
    var obj = {};
    obj.text = $(this).find('label').html();
    obj.value = $(this).find('input').val();
    OutGoings.OutGoing = obj;
});

var DTO = { 'OutGoings': OutGoings };

function callBack(response) {
    //Handel my webmethods response
}

ajaxCall(DTO, 'visualise-my-outgoings.aspx/getPieData', callBack, false);

My web method needs to accept the JSON Object and make it usable so I can loop over the txt value and labels and perform some db interactions and further logic

[WebMethod]
public static string getPieData(OutGoings OutGoings)
{
    //Handel the object
}

public struct OutGoings
{

}

So… I have two questions

  • Am i creating the correct JSON object to push to my web method
  • How do I deserialise the object in my webmethod and what structure should my ‘OutGoings’ struct take?

    • 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-05-27T21:40:04+00:00Added an answer on May 27, 2026 at 9:40 pm

      You probably need a collection of OutGoing:

      public class OutGoing
      {
          public string Label { get; set; }
          public string Value { get; set; }
      }
      

      in your page method:

      [WebMethod]
      public static string GetPieData(OutGoing[] outGoings)
      {
          // Handle the object
      
          return "Hello World";
      }
      

      and finally the client simply fill this collection by looping through the li elements:

      var outGoings = $('#ulOutgoing li').map(function() {
          return {
              Label: $('label', this).html(),
              Value: $('input', this).val()
          };    
      }).toArray();
      

      and then POST it to the page method:

      $.ajax({
          url: 'visualise-my-outgoings.aspx/GetPieData',
          type: 'POST',
          contentType: 'application/json; charset=utf-8',
          data: JSON.stringify({ outGoings: outGoings }),
          success: function(result) {
              // TODO : process the results
              alert(result.d);
          }
      });
      

      The JSON.stringify method is what properly serializes the javascript array into a JSON string. It is natively built-in modern browsers. If you need to support legacy browsers you might need to include the json2.js script to your page.

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

    Sidebar

    Related Questions

    Based on the following code, can you tell me how to refresh the PreferenceActivity
    I am currently running the following code based on Chapter 12.5 of the Python
    My question is concerning SQL connection status, load, etc. based on the following code:
    In the following code, the stack-based variable 'ex' is thrown and caught in a
    I have the following code in WCF service to throw a custom fault based
    Gday All, The following code displays a div based on the option that has
    I have the following HTML code based on a tab menu format, i.e: <div
    Based on my question - take the following code: class Nevermore60Customer: GenericCustomer { public
    I have dynamic grid-based tables in the application I am developing. The following code
    The following is based on the code that I posted on this thread .

    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.