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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:01:05+00:00 2026-06-05T23:01:05+00:00

I am working on an ASP.NET web application. I want to use Jquery ajax

  • 0

I am working on an ASP.NET web application.

I want to use Jquery ajax to call a web service. The webservice will return a string.

This is my webservice:

[WebService(Namespace = "http://localhost/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class MyWebService : System.Web.Services.WebService
{

    [WebMethod]
    public string GetStringForPerson(string Personname, int StartYear, int EndYear)
    {
        string S = "Hello" + Personname + " You where born between " + StartYear + " and " + EndYear;
        return S;
    }
}

And the Ajax function that will call it:

function GetStringForPerson(Name) {
        $.ajax({
            type: "POST",
            url: "Service/MyWebService.asmx/GetStringForPerson",
            dataType: "json",
            data: "{'Personname':Name, 'StartYear':'2001', 'EndYear':'2005'}",
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                alert(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(textStatus);
                alert(XMLHttpRequest.status);
                alert(errorThrown);
            }
        });
    }

But when I call it, I am getting an error 500, “internal Server Error”

I placed a break point in the web method but it is not reaching it.

What might be the problem?

Thanks

  • 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-06-05T23:01:07+00:00Added an answer on June 5, 2026 at 11:01 pm

    One bug that I see is the Name variable, is not send as string and not as variable as it is.
    So change this line as :

    data: "{'Personname':'" + Name + "', 'StartYear':'2001', 'EndYear':'2005'}",
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a ASP.NET MVC3 web application and I want to create a
i'm working on asp.net web application. please guide me for url rewriting in asp.net:
Here I am working with asp.net web application, I am using 2 facebook plugin
I am working on a ASP.NET web application that tryies to download some files
I'm working on a asp.net web application and one of the requirements is that
I'm working on ASP.net MVC3 Web application that is facing scalability issue. For improving
I'm working on Asp.net MVC3 web application. I'm having one page on which appx.
I ran into this dilemma when working on an ASP.net web application using Web
I am working on a ASP.Net web forms application which I inherited from a
I'm working on my first asp.net/web development application. Obviously, I'm very new to asp.net

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.