title: Ajax freezes page after data loaded
body: <p>I am working on C9 IDE on a django project using the django server. I need to update three sections with Ajax request. Mostly this works OK, but sometimes (1 in 10) after the new data is visible (so, request successful) the site completely freezes (not even F5 works). Freez affects all sections not only those updated by request. Browser throws no error, I see the data, so nothing went wrong. But besides scrolling nothing responds. Refresh works only when re-entering the url.</p>
  
  <p>Not sure what to show you, as there is no error, so I load jquery like this on top of home.html:</p>
  
  <pre><code>&lt;script src="//code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
  &lt;script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&gt;&lt;/script&gt;
  &lt;html&gt;
  </code></pre>
  
  <p>Ajax request looks like this:</p>
  
  <pre><code>function get_sid(go2url) {
  var wait_sid = document.getElementById('wait_sid');
  wait_sid.style.display = "initial";
  
  //$('#sidebar').fadeTo(250,0.25);
  $.ajaxSetup({ 
   beforeSend: function(xhr, settings) {
       function getCookie(name) {
           var cookieValue = null;
           if (document.cookie &amp;&amp; document.cookie != '') {
               var cookies = document.cookie.split(';');
               for (var i = 0; i &lt; cookies.length; i++) {
                   var cookie = jQuery.trim(cookies[i]);
                   // Does this cookie string begin with the name we want?
               if (cookie.substring(0, name.length + 1) == (name + '=')) {
                   cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                   break;
               }
           }
       }
       return cookieValue;
       }
       if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
           // Only send the token to relative URLs i.e. locally.
           xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
       }
   } 
  });
  var currentRequest = null;
  currentRequest = $.ajax({
      type: "GET",
      url: go2url,
      data: {},
      async:  true,
      timeout: 15000,
      beforeSend : function()    {
          if(currentRequest != null) {
              currentRequest.abort();
          }
      },
      success: function(data){
          $('#sidebar').load(go2url);
          //$('#sidebar').fadeTo(350,1);
          wait_sid.style.display = "none";     
      }, 
  
      error: function(XMLHttpRequest, textStatus, errorThrown) {
          alert('Loading seems to have encoutered an error. Please try 
  
  again.'+textStatus);wait_sid.style.display = "none";//$('#sidebar').fadeTo(350,1);
  
      }
  });
  }
  </code></pre>
  
  <p>At first I've been thinking the fade function is broken, but the issue persist after removing it. If request is sync or async does not change freez occurence. Timeout is not helping either (I hoped it would break whatever is freezing the browser, it does not). I am no expert in ajax or jquery, from what I read about this, in last three days, searching for a solution - everything is setuped OK. It should work perfectly, shouldn't it?</p>