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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:04:38+00:00 2026-05-10T21:04:38+00:00

I am using .Net framework 2.0 / jQuery to make an Ajax call to

  • 0

I am using .Net framework 2.0 / jQuery to make an Ajax call to a 2.0 web service. No matter what I set the contentType to in the ajax call, the service always returns XML. I want it to return Json!

Here is the call:

      $(document).ready(function() {          $.ajax({             type: 'POST',             url: 'DonationsService.asmx/GetDate',             data: '{}',             contentType: 'application/json; charset=utf-8',             dataType: 'json',             success: function(msg) {               // Hide the fake progress indicator graphic.               $('#RSSContent').removeClass('loading');                // Insert the returned HTML into the <div>.               $('#RSSContent').html(msg.d);             }           });         });     

Here is what the request header looks like in Fiddler:

POST /DonationsService.asmx/GetDate HTTP/1.1 x-requested-with: XMLHttpRequest Accept-Language: en-us Referer: http://localhost:1238/text.htm Accept: application/json, text/javascript, */* Content-Type: application/json; charset=utf-8 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; eMusic DLM/4; .NET CLR 2.0.50727) Host: localhost:1238 Content-Length: 2 Connection: Keep-Alive Pragma: no-cache 

I have tried setting the contentType to ‘text/json’ and get the same results.

Here is the web service method:

<WebMethod()> _ Public Function GetDate() As String      'just playing around with Newtonsoft.Json     Dim sb As New StringBuilder     Dim sw As New IO.StringWriter(sb)     Dim strOut As String = String.Empty      Using jw As New JsonTextWriter(sw)         With jw             .WriteStartObject()             .WritePropertyName('DateTime')             .WriteValue(DateTime.Now.ToString)             .WriteEndObject()         End With         strOut = sw.ToString     End Using      Return strOut  End Function 

and here is what it returns:

<?xml version='1.0' encoding='utf-8'?> <string xmlns='http://DMS.Webservices.org/'>{'DateTime':'11/13/2008 6:04:22 PM'}</string> 

Does anyone know how to force the web service to return Json when I ask for Json?

Please don’t tell me to upgrade to .Net Framework 3.5 or anything like that (I’m not that stupid). I need a 2.0 solution.

  • 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. 2026-05-10T21:04:38+00:00Added an answer on May 10, 2026 at 9:04 pm

    It’s no problem to return JSON from ASMX services in ASP.NET 2.0. You just need the ASP.NET AJAX Extensions installed.

    Do be sure to add the [ScriptService] decoration to your web service. That’s what instructs the server side portion of the ASP.NET AJAX framework to return JSON for a properly formed request.

    Also, you’ll need to drop the ‘.d’ from ‘msg.d’ in my example, if you’re using it with 2.0. The ‘.d’ is a security feature that came with 3.5.

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

Sidebar

Related Questions

I'm using the ASP.NET MVC Framework, jQuery and Ajax calls to do some Partial
Is it possible to make a site with ASP.NET MVC Framework using .NET 2.0?
I have created a web service in .Net 4.0 framework as well as an
I am trying to leverage ORM given the following requirements: 1) Using .NET Framework
I wonder if is possible to use FTS with LINQ using .NET Framework 3.5.
We have an application written in C#, using .NET Framework 3.0 or 3.5 or
Using the .net framework you have the option to create temporary files with Path.GetTempFileName();
Using the .NET framework, I'm trying to replace double slash characters in a string
Using the .Net Framework 1.1, what options are available for monitoring threads from other
How could I restart or shutdown Windows using the .NET framework?

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.