title: Ajax call to twitter and setting up an error or failure function
body: <p>I have code on my site that uses ajax to pull in my twitter feed. It works excellent at the moment but my issue is that when the twitter call does not happen or if I am in a place that has twitter blocked via a firewall all I see is a blank area. I would love to have an error function that would let users know. "There was a error loading the twitter feed, Please trying again later."</p>
  
  <p>Here is the code so far;</p>
  
  <pre><code>(function($) {
  $.fn.twitscroller = function(options) {
      var
      defaults = {
          user: null,
          visible: 1,
          speed: 8000,
          vertical: true,
          count: 10
      },
      settings = $.extend({},
      defaults, options);
  
      this.each(function() {
  
          var $this = $(this);
          $this.html('');
          $this.addClass('twitscroller-replace');
  
          $.ajax({
              type: "GET",
              url: "http://twitter.com/status/user_timeline/" + settings.user + ".json?callback=?",
              data: {
                  count: settings.count
              },
              dataType: "jsonp",
  
              success: function(res) {
                  $('&lt;ul&gt;').appendTo('.twitscroller-replace')
                  $(res).each(function(i, val) {
                      var title = val.text
                      .replace(/\b(https?|ftp|file):\/\/[\-A-Z0-9+&amp;@#\/%?=~_|$!:,.;]*[A-Z0-9+&amp;@#\/%=~_|$]/ig, '&lt;a href="$&amp;"&gt;$&amp;&lt;/a&gt;')
                      .replace(/@(\w*)\b/ig, '@&lt;a href="http://twitter.com/$1"&gt;$1&lt;/a&gt;')
                      .replace(/#(\w*)\b/ig, '&lt;a href="http://twitter.com/search?q=%23$1"&gt;#$1&lt;/a&gt;');
                      time = TwitterDateConverter(val.created_at);
                      var link = "http://twitter.com/daspixl/statuses/" + val.id;
                      if (val.source == '&lt;a href="http://bit.ly" rel="nofollow"&gt;bitly&lt;/a&gt;') {
                          val.source = val.source.replace(val.source, '&lt;a href="http://s.daspixl.com" rel="nofollow"&gt;http://s.daspixl.com&lt;/a&gt;');
                      }
                      var source = val.source
                      $('&lt;li&gt;&lt;/li&gt;')
                      .html('&lt;span class=\"title\"&gt;' + title + '&lt;/span&gt;')
                      .append('&lt;br /&gt;&lt;span class=\"date\"&gt;' + time + '&amp;nbsp; via &amp;nbsp;' + source + '&lt;/span&gt;')
                      .appendTo('.twitscroller-replace ul');
                  });
                  $('.twitscroller-replace').jCarouselLite({
                      vertical: settings.vertical,
                      visible: settings.visible,
                      auto: settings.speed
                  });
                  $('.twitscroller-replace').removeClass('twitscroller-replace');
              }
          });
      });
      return this;
  }   
  })(jQuery);
  
  function TwitterDateConverter(time){
  var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")),
      diff = (((new Date()).getTime() - date.getTime()) / 1000),
      day_diff = Math.floor(diff / 86400);
  
  if ( isNaN(day_diff) || day_diff &lt; 0 || day_diff &gt;= 31 )
      return;
  
  return day_diff == 0 &amp;&amp; (
          diff &lt; 60 &amp;&amp; "just now" ||
          diff &lt; 120 &amp;&amp; "1 minute ago" ||
          diff &lt; 3600 &amp;&amp; Math.floor( diff / 60 ) + " minutes ago" ||
          diff &lt; 7200 &amp;&amp; "1 hour ago" ||
          diff &lt; 86400 &amp;&amp; Math.floor( diff / 3600 ) + " hours ago") ||
      day_diff == 1 &amp;&amp; "Yesterday" ||
      day_diff &lt; 7 &amp;&amp; day_diff + " days ago" ||
      day_diff &lt; 31 &amp;&amp; Math.ceil( day_diff / 7 ) + " weeks ago";
  };
  </code></pre>
  
  <p>Any help would be great.</p>
  
  <p>Thank you,
  James</p>