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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:48:18+00:00 2026-05-27T08:48:18+00:00

I am working on a webservice and a jQuery AJAX. It would take a

  • 0

I am working on a webservice and a jQuery AJAX. It would take a modal dialog and get the inputs from the modal dialog put it into an object and then return a boolean result back from the webservice to the jQuery AJAX call.

Here is the code:

$('[id*="dialog"]').dialog({
    autoOpen: false,
    modal: true,
    resizable: false,
    show: "blind",
    hide: "puff",
    buttons: {
        'Create': function() {
            Materials.MaterialName = $('[id*="txtMaterialName"]').val();
            Materials.QuantityType = $('[id*="txtquantity"]').val();
            var jsonMaterial = JSON.stringify(Materials);
            AddNewMaterial(jsonMaterial);
            $(this).dialog('close');
        },
        'Cancel': function() {
            $(this).dialog('close');
        }
    },
    close: function() {
         window.document.location = "ResourcePlanningMaster.aspx";          
    }
});

function AddNewMaterial(materials) {
$.ajax({
    type: 'POST',
    contentType: "application/json; charset=utf-8",
    url: 'Services/Service.asmx/AddNewMaterial',
    data: '{"Materials":"' + materials + '"}',
    dataType: "json",
    success: function(data, textStatus) {
        if (textStatus == "success") {
            if (data.d == true) {
                alert('New Item Added');
            }
        }
    },
    error: function(data, textStatus) {
        alert('An error has occured retrieving data!');
    }
});

}

and the web service is as :

[WebMethod]
    [ScriptMethod]
    public String AddNewMaterial(String Materials)
    {
        Boolean Result = false;
        try
        {

            MaterialEntity Material = JsonConvert.DeserializeObject<MaterialEntity>(Materials);
            Result = JsonHelper.InsertMaterial(Material);
        }
        catch (Exception ex)
        {

            logger.Error(ex.Message);
            logger.Fatal(ex.InnerException);
        }
        return Result.ToString();
    }

the MaterialEntity Class :

 public class MaterialEntity
{
    public String MaterialName { get; set; }
    public String QuantityType { get; set; }
}

Now when I am invking the create button in web service then the error I am getting in data.responseText is :

{"Message":"Invalid object passed in, \u0027:\u0027 or \u0027}\u0027 expected. (17): {\"Materials\":\"{\"MaterialName\":\"assd\",\"QuantityType\":\"asd\"}\"}","StackTrace":"   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32 depth)\r\n   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n   at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n   at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)\r\n   at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer serializer)\r\n   at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n   at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.ArgumentException"}

Why am I getting this, even though I am parsing it quite correct as a json and then deserializing it as MaterialEntity Class itself? What’s causing this error?

  • 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-27T08:48:19+00:00Added an answer on May 27, 2026 at 8:48 am

    Try to use next code

    data: ‘{“Materials”:’ + materials + ‘}’,

    instead of data line in your example (without double quotes around MaterialEntity object).

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

Sidebar

Related Questions

Heh, I'm using jQuery AJAX Call to pull data from a self hosted webservice
I'm trying to get a jsonp callback working using jquery within a greasemonkey script.
I'm filling some labels using jQuery AJAX and it's working properly (i'm getting the
Guys, I can't seem to get the object serialization working correctly clientside for my
I'm trying to get a simple Spring.NET webservice working with MVC3 but although there
I was today trying to figure out on working with WebService and found many
Working with C# and Team Foundation Server I am working on a webservice that
I am currently working with a webservice to pull a report about users in
I am working with the iPhone SDK and I have to process a webservice
As we are working locally so our service link is: http://localhost:8012/webservice.asmx When we deploy

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.