title: jquery cross domain ajax requests - IE8 and IE9 - YouTube API v3 - jsonp only?
body: <p>I just re-factored a bunch of code to connect to the YouTube API version 3 to find out that none of my ajax calls were working on IE8 and IE9. This had to do with how these versions of IE make cross domain ajax requests (they use MS XDomainRequest, which is not supported in jquery).</p>
  
  <p>My old code was making jsonp requests and it worked on IE8 and IE9. My new code was making regular json requests eg: <code>$.ajax({dataType:'json', ...})</code> instead. I didn't realize that this would not work in IE8 and IE9.</p>
  
  <p>One downside of making jsonp requests is that you cannot capture timeouts through the error callback of the ajax request because the server never responds, which means your callback will never get called. The way I handle this is (is there a better way??):</p>
  
  <pre><code>var timer = setTimeout(function () {
      // a timeout occurred after 30 seconds
  }, 30000);
  
  $.ajax({
      url: url + 'https://www.googleapis.com/youtube/v3/... &amp;callback=?',
      type: 'get',
      dataType: 'jsonp',
      success: function (json) {
          clearTimeout(timer);
          // success!
      },
      error: function (xhr) {
          clearTimeout(timer);
          o.fnError(getAjaxError(xhr));
      }
  });
  </code></pre>
  
  <p><strong>My question is:</strong> is this the best way to make calls into the YouTube API v3 using jquery and ajax?</p>