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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:04:32+00:00 2026-05-12T07:04:32+00:00

I am finding many solutions to this seemingly common problem, but alas, none seem

  • 0

I am finding many “solutions” to this seemingly common problem, but alas, none seem to work for me – of course. I have some jQuery code that is trying to post to an ASP.NET 3.5 web service. The web service is supposed to return some json. I am getting 501 Internal Server errors with the code below, but according to the solutions found online, this is how it is supposed to be! The error function in the jquery code displays a parsererror. If I change how the data parameters are passed to the service ("userID=3456"), and remove the contentType property and change the dataType to “text”, then no errors, but it returns the JSON in an XML string.

Here is my jQuery code:

$.ajax({
        type: "POST",
        url: "mywebservice.asmx/Initialize",
        data: "{'userID': '3456'}",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function(result) {
            alert("success");
        },
        error: function(request, status, errorThrown) {
            alert(status);
            alert(errorThrown);
        }
});

Here is my ASP.NET code:

<WebMethod()> _
Public Function Initialize(ByVal userID As Integer) As String
    Dim scormInstance As New CMI(userID)
    Return scormInstance.ToJsonString
End Function

Here are the HTTP request and response through my browser (Firefox 3.5.1)

http://localhost/cognition/webservices/cognitionapi.asmx/Initialize

POST /cognition/webservices/cognitionapi.asmx/Initialize HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1 (.NET CLR 3.5.30729)
Accept: application/json, text/javascript, */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Content-Type: application/json; charset=utf-8
X-Requested-With: XMLHttpRequest
Referer: http://localhost/cognition/scorm-test2.html
Content-Length: 20
Cookie: RadEditorGlobalSerializeCookie=[_ctl0__ctl0__ctl0_Content_mainContent_mainContent_txtSpecialInstructionsModules]-[]#[_ctl0__ctl0__ctl0_Content_mainContent_mainContent_txtSpecialInstructionsToolbars]-[]#
Pragma: no-cache
Cache-Control: no-cache
{"userID":"1234"}

HTTP/1.x 500 Internal Server Error
Cache-Control: private
Content-Length: 4956
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.0
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Mon, 27 Jul 2009 21:24:41 GMT

Any ideas as to what exactly I am doing wrong????!!!!???

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-05-12T07:04:32+00:00Added an answer on May 12, 2026 at 7:04 am

    After looking at some code i have that’s working i found this decoration on the function:

    [WebMethod(), ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
    

    also the postdata im passing in is in Json format, ie:

    var postdata = "{'variable':'value'}";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a pretty basic scenario but I'm not finding too many helpful resources.
I'm interested in finding out why this is used on some Web sites for
I have tried many algorithms for finding π using Monte Carlo. One of the
Finding a good way to do this has stumped me for a while now:
I keep finding that if I have nested divs inside each other, and one
I'm finding a couple for Java in general but no plugins for netbeans that
I've got some entities which have decimal properties on them. These entities' properties are
I have a JLabel that needs to display some html-formatted text. However, I want
I have a web page with many (up to 100+) html elements on it.
I'm having trouble finding examples of ASP.NET MVC solutions that use EF4 in their

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.