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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:13:40+00:00 2026-05-15T20:13:40+00:00

Im trying to run a sipmle ASP.NET 2 Webmethod with JSON this is my

  • 0

Im trying to run a sipmle ASP.NET 2 Webmethod with JSON
this is my code :

<head>
<title></title>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.3.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {

        $("#btGetDate").click(function () {
            $.ajax({
                type: "POST",
                url: "GetDate.asmx/HelloWorld",
                data: "{}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                    alert(0);
                },
                error:
               function (XMLHttpRequest, textStatus, errorThrown) {
                   $('div#dvDate').html( errorThrown + textStatus);
               }
            });

        });
    });
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="dvDate"></div><input id="btGetDate" type="button" value="Get Date" />
</div>
</form>
</body>
</html>

And The webservice

namespace AJAX_METHODS
{
    /// <summary>
    /// Summary description for GetDate
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]

    public class GetDate : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod]
        public string GetDateTime()
        {
            return DateTime.Now.ToString();
        }
    }
}

I get a parse error back, no idea why.

Thanks for the answers.

  • 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-15T20:13:41+00:00Added an answer on May 15, 2026 at 8:13 pm

    You forgot to indicate that this service should return JSON by decorating it with the [ScriptService] attribute:

    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [ScriptService]
    public class GetDate : System.Web.Services.WebService
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run a simple query with PDO in PHP. The code is
I'm trying to run a simple query with $this->db in Kohana, but am running
I am trying to run this dreadfully simple command in Bash java -cp nasa-top-secret.jar
I am trying to run the following simple code, public abstract class Shape{ abstract
I have an ASP.NET site that I am maintaining. Currently it has code that
I was trying to build a social networking site from ASP.NET 3.5 Social Networking
I am trying to run simple perl dbi example script to connect to mysql
I'm trying to run a simple query with node-mysql like this: client.query(UPDATE mytable SET
I'm trying to create a simple Asp.Net page to read Perfmon counters from a
I am trying to run simple code from examples: require.paths.unshift('/etc/npm'); // path to modules

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.