Click here to Skip to main content
14,298,693 members
Rate this:
Please Sign up or sign in to vote.
Dear All,

i have WebService that get 2 string and return if they equals

WebService that in

[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class Service1 : System.Web.Services.WebService
         [WebMethod(Description = "Validate the login credentials")]
         public bool Validate(string UserName, string Password)
              if (Password == "test" && UserName == "test")
                  return true;
                  return false;

and i have html page that call this WebService and need to return the Result

<html  lang="en-US">
         <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
         <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
         <script type="text/javascript" language="javascript">

         var Surl = "http://localhost:3031/WS_HTML/Service1.asmx/Validate";

         $(document).ready(function () {
             $("input#submit").click(function (event) {
                 //var uid = document.getElementById("UserName").value;
                 //var pwd = document.getElementById("Password").value;

                 var uid = "test";
                 var pwd = "test";

                 var dataString = "{ 'UserName' : '" + uid + "', 'Password' : '" + pwd + "'}";

                     ServiceCallID: 1,
                     url: Surl,
                     type: 'POST',
                     data: dataString,
                     contentType: "application/json; charset=utf-8",
                     dataType: "json",

                     success: function (result) {
                         returnVal = result.d;

                     error: function (XMLHttpRequest, textStatus, errorThrown) {
                         returnVal = '';


     <body >
         <form method=post runat="server">
             <input  type="submit" />Connet to my WS

I swear to God that for several days I break my head and can not figure out why it does not work


Updated 6-Sep-19 10:27am
Do you see any errors logged in console tab of Developer Tool? Have you debugged the code?
Kornfeld Eliyahu Peter 13-Jul-14 9:10am
Are you sure that the connection made over port 3031? Maybe it's a dynamic port assigned by VS?
goldsoft 13-Jul-14 10:07am
i see that Nothing happens
Ranjeet Patel 14-Jul-14 3:27am

Try to run both the upper links and verify if one of those works, It works then
ServiceCallID: 1,
from this line try to remove the ServiceCallID:1, and see if any luck..
goldsoft 14-Jul-14 6:59am
Ranjeet Patel 14-Jul-14 8:31am
See that means your service is not working... so any client can not use your service.
make sure that your service is accessible and running always.
Rate this:
Please Sign up or sign in to vote.

Solution 1

You said the url is at[^] and in your code you have a different url, http://localhost:3031/WS_HTML/Service1.asmx/Validate[^]

All you need to do; however, is debug it. Put a breakpoint on your error function and see what the values are.
Rate this:
Please Sign up or sign in to vote.

Solution 2

Ypu have specified in jquery that output from web method is in JSON foormat
(dataType: "json",)

Add this before web method if you are about to return output as JSON
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
Rate this:
Please Sign up or sign in to vote.

Solution 3


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100