title: TypeError: $(...).unload is not a function - JQuery 3.1.0
body: <p>I'm trying to execute a function before redirecting to other page, but when the original page loads I get the error that I wrote in the title:</p>
  
  <pre><code>TypeError: $(...).unload is not a function
  </code></pre>
  
  <p>I've tried this:</p>
  
  <pre><code>$( window ).unload(function() {
    return "Bye now!";
  });
  </code></pre>
  
  <p>And this:</p>
  
  <pre><code>$(window).unload(function(){
    cambiar_ruta();
    alert(ruta);
  });
  </code></pre>
  
  <p>But nothing is working,I don't even get a Leaving page warning.</p>
  
  <p>With next code I don't get an error, but the function is never triggered and the alert never shown:</p>
  
  <pre><code>var ruta;
  $(window).bind('onbeforeunload', function(e){
    alert('Bye.');
    cambiar_ruta();
    alert(ruta);
  });
  </code></pre>
  
  <p>I'm using jquery-3.1.0.min</p>