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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:48:01+00:00 2026-05-26T18:48:01+00:00

Found a great article about using jQuery to consume a codebehind WebMethod. I am

  • 0

Found a great article about using jQuery to consume a codebehind WebMethod. I am trying to apply it on my website. But I keep getting the following error though I ensured that the param names are the same.

        $(".StreamLike").live("mouseover", function () {
            var Id = $(this).parent().parent().find(".StreamIndex").html();
            alert(Id);
            $.ajax({
                type: 'POST',
                url: 'Default.aspx/GetLikes',
                data: { "Id": Id },
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                success: LikesSuccess,
                error: LikesError
            });
        }); 

        function LikesSuccess(result, userContext, methodName) {
            for (var i in result) {
                alert(result[i]); 
            }

WebMethod:

[WebMethod]
public static string[] GetLikes(int Id)
{
    List<Like> Likes = Like.GetById(Id, false);
    string[] Senders = new string[Likes.Count];
    for (int i = 0; i < Likes.Count; i++)
    {
        Senders[i] = Likes[i].Sender;            
    }
    return Senders;
}

The full error message is as follows:

{“Message”:”Invalid JSON primitive: Id.”,”StackTrace”:” at
System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()\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”}

It’s always hitting LikesError…

  • 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-26T18:48:02+00:00Added an answer on May 26, 2026 at 6:48 pm

    Try this…

    data: JSON.stringify({ “Id”: Id })

    The post is turning your “Id” object into name/value pairs. e.g. Id=12345. You have to stringify the object first.

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

Sidebar

Related Questions

I found a great article on getting started using the Twitter API for authenticating
I found this great Tablesorter plugin for jQuery but I can't make it work
I found a great explanation about the new RTTI in Delphi ,but I don't
I found a great tutorial on performing a faceted search. http://www.devatwork.nl/articles/lucenenet/faceted-search-and-drill-down-lucenenet/ This article does
I found this great article on Transactions with Table Adapters. However, this article doesn't
I'm trying to evaluate the weborb integration product, but I'm having troubles getting it
I'm using Rails' accepts_nested_attributes_for method with great success, but how can I have it
I found a great C++/ODBC example here ... The project I downloaded builds great
I have just found this great tutorial as it is something that I need.
I've found a great datepicker on EveryBlock's web site: http://ui-patterns.com/userset/553/image/2955#focus Does anybody know which

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.