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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:06:48+00:00 2026-05-11T15:06:48+00:00

I am attempting to write an ASP.net web service that will be utilized by

  • 0

I am attempting to write an ASP.net web service that will be utilized by a jQuery AJAX call. I am absolutely at my wit’s end trying to get this to work. I’ve seen a number of similar questions online but I haven’t been able to find a solution that fits.

When I attempt to make the ajax call (via jquery) I get a successful response from the server but the request fails because of a parser error.

I’ve validated the json returned by the webservice and it is valid. The issue seems to stem from the fact that asp.net is returning the json object as xml.

I’ve specified the return type as json using

<Script.Services.ScriptMethod(responseFormat:=Script.Services.ResponseFormat.Json)> _ 

I’ve added the following http handler as it was mentioned as a potential fix

<httpHandlers>     <remove verb='*' path='*.asmx' />     <add verb='*' path='*.asmx' type='System.Web.Script.Services.ScriptHandlerFactory' validate='false' /> </httpHandlers> 

The content Type is set to ‘application/json; charset=utf-8’ and the dataType to ‘json’ in my jquery ajax setup. The request type seems to be correct but the response is always xml.

I can make the request successfully by removing the dataType but i would very much like to avoid using an eval to deserialize the data.

If anyone has any suggestion i will be greatly appreciated. I’ve been pulling my hair out for a few days on this.


JAVASCRIPT

(function($) {   $.ajaxSetup({     type: 'POST',     contentType: 'application/json; charset=utf-8',     global: false,     dataType: 'json'   });    function auto() {     console.log('test');     return;   };    $.fn.species = {     test: function() {       alert('test');     },     load: function() { //load and attach species list to element as dropdown       $.ajax({         url: 'SpeciesService.asmx/List',         success: function(msg) {           console.log(msg);         },         error: function(xhr, desc, exceptionobj) {           console.log(xhr.responseText);           console.log(desc);           console.log(exceptionobj);         }       });       return this;     }   }; //Species Block })(jQuery); //jQuery Alias Block 

ASP.NET Webservice

<%@ WebService Language='VB' Class='SpeciesService' %> Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols Imports Species Imports System.Runtime.Serialization 

‘ To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. ‘ _

_ _ Public Class SpeciesService

Inherits System.Web.Services.WebService <WebMethod()> _ <Script.Services.ScriptMethod(responseFormat:=Script.Services.ResponseFormat.Json)> _ Public Function Data(ByVal id As Integer) As String     Dim curSpecies As New Species(id)     Return curSpecies.serialize End Function  <WebMethod()> _ <Script.Services.ScriptMethod(responseFormat:=Script.Services.ResponseFormat.Json)> _ Public Function List() As String      Return Species.list() End Function 

End Class

  • 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-11T15:06:48+00:00Added an answer on May 11, 2026 at 3:06 pm

    Try posting a dummy json data with JQuery like this :

    $.ajaxSetup({     type: 'POST',     data : '{'foo':'bar'}' ... 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've written a web service using ASP.NET (in C#) and I'm attempting to write
I am attempting to write a javascript heavy portion of my Asp.net MVC Web
I am attempting to write a one-line Perl script that will toggle a line
I am attempting to write a .NET component. The component will be dropped onto
I'm attempting to write an AJAX control extender that can modify an AJAX Control
I am attempting to write a 'User Control' in WinForms .NET (not ASP.NET). The
I'm attempting to write a CompiledQuery using Linq-to-Entities that will replace a stored procedure
I am attempting to write a JS function (using prototype in rails) that will
I'm attempting to write a query that will return The most recent AccountDate with
I've been attempting to write a Lisp macro that would perfom the equivalent of

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.