Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am trying to call the web service web method using jquery ajax. But i dont what is the error in the following jquery script. can any one find the error and give the correct solution. Thanks in advance

JavaScript
$.ajax({
type: "POST",
contentType: "application/json",
url: "WebEmployee.asmx/employeeDetails",
success: function (data) {
//sucess function
},
error: function () {
//error
}
Posted
Comments
King Fisher 20-Mar-15 0:19am    
Do you have Firebug ?
neethu mohan 20-Mar-15 0:21am    
No
King Fisher 20-Mar-15 1:41am    
Install it then find the what is the error.
King Fisher 20-Mar-15 1:43am    
Go to Firefox Add-ons, search for Firebug and Install it. then run your page and hit F12.
F-ES Sitecore 20-Mar-15 5:17am    
Both IE and Chrome have dev tools built-in, no need to install add-ons.

1 solution

Try the following solution
script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <<script>
        $(document).ready(function () {
            $("#btnGet").click(function (e) {
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    contentType: "application/json",
                    url: "WebService.asmx/GetDateAndTime",
                    success: function (data) {
                        $("#DateTime").html(data.d);
                    },
                    error: function () {
                        alert("The call to the web service failed");
                    }
                })
                e.preventDefault();
            });
        });
</script>
</script>


call web service in asp.net using jQuery ajax
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900