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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:25:43+00:00 2026-05-13T05:25:43+00:00

Issue I have an aspx page with jQuery code to send an ajax request

  • 0

Issue

I have an aspx page with jQuery code to send an ajax request over to an asmx web service file (on the same website). The response that comes back is not consistent, however, it consistently fires the “error” jQuery callback as opposed to the “success” call back. The status code inconsistently varies between 200, 12030, and 12031. The responseText of the message to the callback inconsistently varies between [blank] and the actual XML that the json webservice returns. I debugged the code, and the webservice does actually execute without any exceptions.

ASPX Code

//Code omitted for brevity

<script type="text/javascript">
jQuery(document).ready(function()
{
  jQuery.ajax({
  type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "CallDequeue.asmx/Dequeue",
    data: "{}",
    dataType: "json",
    success: function(Msg)
    {
      alert('success:' + Msg.responseText);
    },
    error: function(Msg)
    {
      alert('failed:' + Msg.status + ':' + Msg.responseText);
    }
  });
});
</script>

//Code ommitted for brevity

Web Service Code

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class CallDequeue : System.Web.Services.WebService
{
  [WebMethod]
  public string Dequeue()
  {
    return "{\"d\":{\"FirstName\":\"Keivan\"}}";
  }
}
  • 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-13T05:25:43+00:00Added an answer on May 13, 2026 at 5:25 am

    When you mark the service as a ScriptService, it automatically handles the JSON serialization. You shouldn’t manually serialize the response.

    If you want the return to come back as “FirstName”, then you can use a DTO class to control the syntax. Just returning a string, it would come back as {‘d’:’Keivan’} instead of {‘d’:{‘FirstName’:’Keivan’}}.

    [ScriptService]
    public class CallDequeue : System.Web.Services.WebService
    {
      public class PersonDTO
      {
        public string FirstName;
      }
    
      [WebMethod]
      public PersonDTO Dequeue()
      {
        var p = new PersonDTO();
    
        p.FirstName = "Keivan";
    
        return p;
      }
    }
    

    A few changes to the calling syntax:

    jQuery(document).ready(function() {
      jQuery.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "CallDequeue.asmx/Dequeue",
        data: "{}",
        dataType: "json",
        success: function(Msg) {
          // Unless you're using 2.0, the data comes back wrapped
          //  in a .d object.
          //
          // This would just be Msg.d if you return a string instead
          //  of the DTO.
          alert('success:' + Msg.d.FirstName);
        },
        error: function(Msg) {
          alert('failed:' + Msg.status + ':' + Msg.responseText);
        }
      });
    });
    

    You can read more about ASP.NET AJAX’s .d wrapper here, if you’re interested.

    Update:

    Using ASP.NET 2.0, you need to install the ASP.NET AJAX Extensions v1.0. Additionally, make sure your web.config is configured for ASP.NET AJAX (most specifically the HttpHandlers section).

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

Sidebar

Related Questions

Here is my issue. I have an ASPX web site and I have code
I have a strange issue: I am using SPContext.Current.Web in a .aspx page, but
On an Aspx page, I have this markup (setup for a jQuery UI dialog):
I created a .aspx web page for SharePoint 2010 that uses JQuery to extract
I have an aspx page with an ajax tab container. In a class I
I have an aspx page with a simple form to send emails to pre-defined
I have implemented JQuery FullCalendar by fetching the events dynamically from an aspx page.
I have no issues when doing using JQuery in a aspx page without a
I often have an issue with compile errors when I copy over an aspx
hi i have issue with internet exploerer rendering , i have a aspx page

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.