Thursday, October 3, 2013

How to call Web Service using Jquery AJAX


Here is simple example how to call a web service using Jquery AJAX. Pretty simple HTML file.

The method 'Get' is used to request the data from the server.

<html>
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.9.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        function InvokeAJAXWebService() {

   $.ajax( {
   type:'Get',
   url:'http://www.site.com/mywebservice',
   success:function(data) {
    alert(data);
                        }
   });
       
        }
     
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <button id="btnExample" runat="server" onclick="InvokeAJAXWebService();">
            JQuery AJAX Web Service Example</button>
    </div> 
    </form>
</body>
</html>

No comments:

Post a Comment