Software Technology Tips

If Ajax framework is used, web service and WCF service methods are consumed by ScriptManager. For jQuery framework, these services are consumed by following ways.
Create  Ajax-EnabledWCFService, name it "TimeService.svc".
Put Following code in the TimeService class.
 public string GetTime()
  return "<B>" + "Current Server Time : " + DateTime.Now.ToLocalTime() + "</B>" ;
 <script language="javascript" type="text/javascript" src="jquery-1.2.6.js"></script>
     <script type="text/javascript">
         $(document).ready(function() {
         $("#btnTime").mouseover(function(event) {
                     type: "post",
                     url: "TimeService.svc/GetTime",
                     data: "{}",
                     contentType: "application/json; charset=utf-8",
                     dataType: "json",
                     success: function(msg) {
                     error: ServiceFailed
         function ConsumeService(result) {
         function ServiceFailed(result) {
             alert(result.status + ' ' + result.statusText);
<input id="btnTime" value="Server Time" type="button"  /> 
 <span id="sp"></span>
For WebService create TimeService.asmx.
Put following code in in TimeService Class. 
    public string GetTime()
              return "<B>" + "Curent Server Time : " + DateTime.Now.ToLocalTime() + "</B>";
 Change URL in jQuery $ajax()  to  url: "TimeService.asmx/GetTime"

Related Tags:

Javascript, jQuery, ASP.NET

Author: Jnana Swain


Let us Connect!

Awards and Achievements

Red Herringcolor DeloitteFast50 DB ZInnov1   Nascome  DB Stpi

This site uses cookies. We respect your privacy.copyright (c) Mindfire Solutions 2007-2015. Login