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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:52:31+00:00 2026-05-28T00:52:31+00:00

I am trying to create a webservice that takes data, posts it to a

  • 0

I am trying to create a webservice that takes data, posts it to a database, and returns the result. I know how to write all the C# code that does that, but it is the communication that I am having problems with. At the moment, I am just trying to invoke the service and get back “Hello World” (I start with something simple since I have no idea what I’m doing)…

My Jquery:

$.ajax({
  type: "POST",
  contentType: "application/json; charset=utf-8",
  url: "PersonService.asmx/HelloWorld",
  data: "{}",
  dataType: "json",
  success: function(msg) {
    alert("Success");
    $("#log").html(msg);
    alert(msg);
  }
});

My Webservice:

public class PersonService : System.Web.Services.WebService
{
~

    [WebMethod(CacheDuration = CacheHelloWorldTime,
    Description="As simple as it gets - the ubiquitous Hello World.")]
    public string HelloWorld()
    {
        return "Hello World";
    }
~
}

After using chrome to Inspect the Element, and selecting the Network tab, finding my webservice, it shows me that the result was:

<?xml version="1.0" encoding="utf-8"?>
<string>Hello World</string>

So, it seems that the service executed successfully, but the success function does not fire, and there are no errors in the console. What is going on? Also, why is the result in XML?

Do I need to use Web Services, or could I just post the variables via AJAX to an ASPX page that would process it the same way it would a form submission?

  • 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-28T00:52:32+00:00Added an answer on May 28, 2026 at 12:52 am

    Using jQuery to Consume ASP.NET JSON Web Services » Encosia

    $(document).ready(function() {
      $.ajax({
        type: "POST",
        url: "RSSReader.asmx/GetRSSReader",
        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);
        }
      });
    });
    

    Also, you’re missing [ScriptMethod] on your web service method and [ScriptService] on your service class.

    [WebService]
    [ScriptService]
    public class PersonService : WebService
    {
        [ScriptMethod]
        [WebMethod(CacheDuration = CacheHelloWorldTime,
        Description="As simple as it gets - the ubiquitous Hello World.")]
        public string HelloWorld()
        {
            return "Hello World";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a secure webservice (that provides simple database data) with PHP
I am trying to create an ajax request to a WebService that returns data
I'm trying to create a simple spring based webservice that supports a post with
I am trying to create a webservice that will return jsonp. At the moment
I'm trying create a ASMX webservice that can perform a HTTP GET request. I
I'm trying to create a call to odata webservice that would select only distinct
Im trying to create a web services that takes some arguments in its constructor
Im trying to create a 'jsTree' treeview that gets it's data from a .Net
I'm new to VB and trying to write a webservice that exports and imports
We are trying to create a web-service that we plan to pass a variable

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.