title: Cannot read property 'url' of undefined. jQuery loading widget fails
body: <p>I am trying to build a widget in jQuery to handle loading of content to certain divs on a page. The reason I am doing this is to keep my code DRY. I should perhaps mention that I use HeadJS for javascript loading.</p>
  
  <p>This is my widget code:</p>
  
  <pre><code>(function ($, window, document, undefined) {
  
      $.widget ("my.contentloader", {
  
          options: {
  
              loadingMessage: true,
  
              errorDiv: '#error',
  
              contentDiv: '#content'
  
          },
  
          _create: function () {
  
              $.ajax ({
  
                  type: "POST", 
  
                  url: self.options.url, 
  
                  data: {limit: self.options.params.limit, offset: self.options.params.offset},
  
                  beforeSend: function (html) {
  
                      // Check if loading message should be displayed
  
                      if (self.options.loadingMessage) {
  
                          $(self.options.contentDiv).html ("&lt;div id='loading'&gt;Loading&lt;/div&gt;");
  
                      }
  
                  },
  
                  success: function (html) {
  
                      if (self.options.loadingMessage) {
  
                          $('#loading').remove ();
  
                      }
  
                      $(self.options.contentDiv).html (html);
  
                  },
  
                  error: function (html) {
  
                      $(self.options.errorDiv).html (html);
  
                  }
  
              });
  
          },
  
          _setOption: function (key, value) {
  
              this.options[key] = value;
  
              $.Widget.prototype._setOption.apply (this, arguments);
  
      }
  
      });
  
  })(jQuery, window, document);
  </code></pre>
  
  <p>I include this widget file and jquery on the calling page. Then I use the plugin like this:</p>
  
  <pre><code> $(window).contentloader ({
  
    url: 'loading/content/url'
  
   });
  </code></pre>
  
  <p>The problem is that I get this error:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'url' of undefined
  </code></pre>