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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:20:55+00:00 2026-06-12T09:20:55+00:00

I am using JQuery and Ajax to interface with an ASP.Net web service. Here

  • 0

I am using JQuery and Ajax to interface with an ASP.Net web service. Here is the Jquery code:

$.jrpc = function(url, id, method, params, success, error) {
    var request = $.json_stringify({
       'jsonrpc': '2.0', 'method': method,
        'params': params, 'id': id});
    return $.ajax({
        url: url,
        data: "json=" + encodeURIComponent(request),
        success: success,
        error: error,
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        async: true,
        cache: false,
        //timeout: 1,
        type: 'POST'});
};

Here is the web service code:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class Access : System.Web.Services.WebService
{

    [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string EntryMethod(string json)
    {
        Requests d = JsonConvert.DeserializeObject<Requests>(json);
        Response resp = new Response();
        resp.jsonrpc = d.jsonrpc;
        resp.result = "Got the call!";
        resp.id = d.id;
        resp.error = null;
        JavaScriptSerializer response = new JavaScriptSerializer();
        string r = response.Serialize(resp);

        return r;
    }
}

I am getting this error:

[AJAX] error – Server reponse is:
{“Message”:”Invalid JSON primitive: json.”,”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”}

Using the ASP.Net webservice test page, here are my headers and request string:
Cache-Control: private, max-age=0
Date: Wed, 03 Oct 2012 19:47:16 GMT
Content-Length: 149
Content-Type: text/xml; charset=utf-8
Server: ASP.NET Development Server/10.0.0.0
X-AspNet-Version: 4.0.30319
Connection: Close

json=%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22test%22%2C%22params%22%3A%5B%5D%2C%22id%22%3A1%7D

And here are the headers/request string of my Ajax call which is not working:
Cache-Control: private
Date: Wed, 03 Oct 2012 19:47:09 GMT
Content-Length: 1062
Content-Type: application/json; charset=utf-8
jsonerror: true
Server: ASP.NET Development Server/10.0.0.0
X-AspNet-Version: 4.0.30319
Connection: Close

json=%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22test%22%2C%22params%22%3A%5B%5D%2C%22id%22%3A1%7D

Any ideas as to why I am getting this error? I’ve tried googling it, but none of the results have really helped me.

Edit:

If I use:
data: “{‘jsonrpc’:’2.0′,’method’:’test’,’params’:[],’id’:1}”,

I get this error:
[AJAX] error – Server reponse is:
{“Message”:”Invalid web service call, missing value for parameter: \u0027json\u0027.”,”StackTrace”:” at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary2 parameters)\r\n at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary2 parameters)\r\n at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)”,”ExceptionType”:”System.InvalidOperationException”}

If I use:
data: “json={‘jsonrpc’:’2.0′,’method’:’test’,’params’:[],’id’:1}”,

I get this error:
[AJAX] error – Server reponse is:
{“Message”:”Invalid JSON primitive: json.”,”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”}

  • 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-12T09:20:55+00:00Added an answer on June 12, 2026 at 9:20 am

    change
    data: “json=” + encodeURIComponent(request),
    to
    data: “{json: ‘” + encodeURIComponent(request)+”‘}”,

    see sample code

      $.ajax("WebService.asmx/EntryMethod", {
            contentType: "application/json; charset=utf-8",dataType: "json",
            type: "POST", data: "{json:'value'}", success: function (r) { alert(r); },
            error: function (e) { alert(e); }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an ajax enabled wcf service with a jquery POST method which gets
I am calling an ASP.net application that has an exposed JSON web service interface.
I am using jQuery ajax to pass a string array to a page method.
How to pass multiple checkboxes using jQuery ajax post this is the ajax function
I have created an ASP.NET Webforms web application which basically inetracts with the code
I have added a service reference to my asp.net web application (originally it was
Imagine, I build a complex interface using jQuery/AJAX and want the application with this
I'm using the jQuery AJAX function in order to retrieve data from my mySQL
I am using JQUERY .ajax() to send serialized form data to MySQL using PHP.
I'm having trouble using jQuery.ajax() to post a gist to Github. The gist is

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.