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 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

Ask A Question

Stats

  • Questions 117k
  • Answers 117k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Think I’ve got it. Here’s code which does (in this… May 11, 2026 at 10:42 pm
  • Editorial Team
    Editorial Team added an answer "somevar" could be a 64-bit variable, this code would therefore… May 11, 2026 at 10:42 pm
  • Editorial Team
    Editorial Team added an answer No. alias_method is a standard method from Ruby. alias_method_chain is… May 11, 2026 at 10:42 pm

Related Questions

I have been getting more and more sick of all the quirks about control
I'm in the preliminary stages of designing a new web application, and have yet
Here I have: Public Structure MyStruct Public Name as String Public Content as String
While making some final tests of a class-library that I'm writing for Windows Mobile

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.