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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:32:26+00:00 2026-06-02T12:32:26+00:00

I have a jquery ajax call asp.net web service but it is not working.

  • 0

I have a jquery ajax call asp.net web service but it is not working. I got an error:

isValid is underfined.

I set a breakpoint and found that the code never reaches web service.
Jquery:

<script src="../jquery-1.7.2.min.js" type="text/javascript"></script>
<script>
    function ValidateUserName() {
        var isValid;
        $.ajax({ type: "POST",
            url: "UserNameWebService.asmx/ValidateUserName",
            data: "{'strUsername': '" + $("#<%=TextUserName.ClientID%>").val() + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            async: false,
            success: function (data) {
                isValid = data;
            }
        });
         return isValid;
        } 
</script>

web service code:

 [WebService(Namespace = "http://tempuri.org/")]
[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 UserNameWebService : System.Web.Services.WebService
{

    [WebMethod]
    public bool ValidateUserName(string strUsername)
    {
        \\ then return something by logic

Thank you.

  • 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-02T12:32:30+00:00Added an answer on June 2, 2026 at 12:32 pm

    You are returning isValid before your Ajax is complete.
    The best thing to do is write a function which is called on the completion of your Ajax call.

        $.ajax({ type: "POST",
            url: "UserNameWebService.asmx/ValidateUserName",
            data: "{'strUsername': '" + $("#<%=TextUserName.ClientID%>").val() + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            async: false,
            success: function (data) {
                RenderResult(data);
            }
        });
    

    Then deal with the returned data here.

    function RenderResult(data){
        // handle the returned result here
        var isValid = data;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery ajax call asp.net web service question. I want to validate
I have a web service that returns this string via the jQuery $.ajax() call
I am running ASP.NET MVC Beta. I have an AJAX call running through jQuery
I have an ASP.Net MVC 3 application that uses a jQuery .ajax call to
I am having issues calling an ASP.NET web service in JQuery. I am basically
Actually I am trying to learn jQuery Ajax calls to asp.Net webservices. I have
I am not able to call web service(asmx) from jQuery function. It is saying
I have a ASP.Net web app with jquery implemented on the client side. within
I've a problem...I use jQuery ajax to call a web service that returns XML.
If I use jQuery AJAX to call a specific ASP.NET page method how to

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.