title: jQuery - TypeError: callback is undefined
body: <p>I made one small jQuery plugin for discount and after discounting if I don't use callback function I recive error: "TypeError: callback is undefined"</p>
  
  <p><strong>CODE:</strong></p>
  
  <pre><code>$.fn.countdown = function (options,callback) {
      var settings=$.extend({
          duration        :   0,
          interval        :   1000,
          text_before     :   "",
          text_after      :   "",
          disable         :   false,
      }, options );
      var callback,
          container = $(this[0]).html(settings.text_before + settings.duration + settings.text_after),
          countdown = setInterval(function (){
          var dd = --settings.duration;
          if(settings.disable==true){
              clearInterval(countdown);
          }
          else if (dd &gt; 0){
              container.html(settings.text_before + dd + settings.text_after);
          } else {
              clearInterval(countdown);
              callback.call(container);   
          };
      }, settings.interval);
  };
  </code></pre>
  
  <p><strong>EXAMPLE 1 - Using Callback function:</strong></p>
  
  <pre><code>$("#timer").countdown({
              duration    :   3,              // Discount start from defined number (in this case 3 seconds) DEFAULT: 0
              text_before :   "Redirection begins in exactly ",   // initial text before number (example: Redirection begins in exactly 3), DEFAULT: blank
              text_after  :   " seconds"  // initial text after number (example: 3 seconds), DEFAULT: blank
          },
          // callback function when discount stop on 0
          function(){
              this.html("Done counting, redirecting.");
              window.location = "http://www.creativform.com";
          });
  </code></pre>
  
  <p><strong>EXAMPLE 2 - Without callback function:</strong></p>
  
  <pre><code>$("#timer").countdown({
              duration    :   3,              // Discount start from defined number (in this case 3 seconds) DEFAULT: 0
              text_before :   "Redirection begins in exactly ",   // initial text before number (example: Redirection begins in exactly 3), DEFAULT: blank
              text_after  :   " seconds"  // initial text after number (example: 3 seconds), DEFAULT: blank
          });
  </code></pre>
  
  <p>Any help?</p>