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 8439329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:58:54+00:00 2026-06-10T07:58:54+00:00

I am using AJAX to pass a JSON Array to a .NET web service.

  • 0

I am using AJAX to pass a JSON Array to a .NET web service. The Stringified JSON array is correct when sent – I show the content in a JS alert – but when I output it within the web service, it just displays null values.

Help.

The JS is this:

                var listitems = [];
                $('#job-item-list').children('.iamalistitem').each(function () {
                    listitems.push({ "title": $(this).find('.job-item-title').text(), "price": $(this).find('.job-item-price').text().replace("£","").replace("£","") });
                });
                alert(JSON.stringify({ ListItems: listitems }));

                $.ajax({
                    type: "POST",
                    url: "/ld_jobs.asmx/putJobItems",
                    // The key needs to match your method's input parameter (case-sensitive).
                    data: JSON.stringify({ ListItems : listitems }),
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (response) {
                        var responseObjTwo = JSON.parse(response.d);
                        //showUserMessage(responseObjTwo.Message, false);
                        showUserMessage(response.d, false);
                    },
                    error: function (response) {
                        var responseObj = JSON.parse(response.responseText);
                        showUserMessage(responseObj.Message, true);
                    }
                });

The receiving service is this:

    public class ListItem
    {
        public string itemTitle { get; set; }
        public decimal itemPrice { get; set; }
    }

    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string putJobItems(ListItem[] ListItems)
    {
        // Add to DB
        int errorNumber = 0;
        try
        {
            // check if on DB already
            string returnstring = "";
            errorNumber++; //1
            foreach (ListItem item in ListItems)
            {
                errorNumber++; //2,3,4
                returnstring += "Desc: " + item.itemTitle + "; Price: " + item.itemPrice.ToString() + "; ";
            }
            errorNumber++; //5
            return "{ \"Status\" : \"Success\", \"Message\" : \"Your request has been successfully posted.  Well done you.  Go put the kettle on and be lazy! \", \"input\" : \"" + returnstring + ": " + errorNumber.ToString() +  "\" }";
        }
        catch (Exception ex)
        {
            Exception newEx = new Exception("Well this is quite embarassing.  It seems the badgers have escaped! (Actual error: " + ex.Message + "; error: " + errorNumber.ToString() + ")");
            throw newEx;
        }
    }

The Stringyfied field going in is:

{"ListItems":[{"title":"(Groceries) 4 pints of milk","price":"2.00"},{"title":"(Groceries) 2 loafs of bread","price":"3.00"},{"title":"(Subway) Foot Long BMT","price":"3.00"}]}

Response.d comes back as:

{ "Status" : "Success", "Message" : "Your request has been successfully posted. Well done you. Go put the kettle on and be lazy! ", "input" : "Desc: ; Price: 0; Desc: ; Price: 0; Desc: ; Price: 0; : 5" }

Any help greatly appreciated. Thanks.

  • 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-10T07:58:56+00:00Added an answer on June 10, 2026 at 7:58 am

    You are use title and price properties names on client but itemTitle and itemPrice on server. Adjust them to use same names.

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

Sidebar

Related Questions

I am using jQuery ajax to pass a string array to a page method.
Im using JSON.NET do deserlaize an object, but i cant get it to work
On using jQuery ajax on ASP.Net, we are required to pass the DATA through
For this question, I'm using ASP.NET Web Forms in C#, a web service and
I use the Symfony PHP MVC framework. I'm using JSON to pass an AJAX
When using the Ajax.BeginForm() helper in ASP.Net MVC , I can pass options with
Hi all i am using json to pass data in wcf service. Below is
I have a form that I am using AJAX to pass values with. The
So I'm using an ajax request to pass some data for filtering purposes. Then
How to pass multiple checkboxes using jQuery ajax post this is the ajax function

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.