Saturday, April 14, 2012

jQuery Countdown Timer


A jQuery plugin that sets a div or span to show a countdown to a given time.


Usage

  1. Include the jQuery library in the head section of your page.
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
  2. Download and include the jQuery Countdown CSS and JavaScript in the head section of your page.
    <style type="text/css">@import "jquery.countdown.css";</style> 
    <script type="text/javascript" src="jquery.countdown.js"></script>
    Alternately, you can use the packed version jquery.countdown.pack.js (10.0K vs 30.1K), or the minified version jquery.countdown.min.js (12.6K, 4.3K when zipped).
  3. Connect the countdown functionality to your divs.
    $(selector).countdown({until: liftoffTime});
    You can include custom settings as part of this process.
    $(selector).countdown({until: liftoffTime, format: 'dHM'});

WebService: Request format is unrecognized for URL unexpectedly ending in {/MethodName}

All you need is to add the following to your web.config

<webServices>
     <protocols>
          <add name="HttpGet" />
          <add name="HttpPost" />
     </protocols>
</webServices>

and call the service this way

<script type="text/javascript">
$.ajax({
       type: "POST",
       url: "CatsService.asmx/GetCatsByID",
       data: "{id: " + li.attr("rel") + " }",
       contentType: "application/json; charset=utf-8",
       dataType: "json",
       success: function (o) {
           o = o.d;
           for (var i = 0; i < o.length; i++) {
           $('ul').append('<li><a href="javascript:void(0)">' + o[i].title + '</a></li>');
           }
       }
});
</script>

All is done