title: How to use ajax with blueprints in flask
body: <p>I would like to define a global ajax function that I will use to unlock models in case a window closes unexpectedly. </p>
  
  <pre><code>@main.route('_unlockmodels')
  def unlockmodels():
      .. unlock stuff ..
      return None
  </code></pre>
  
  <p>and then the actual ajax</p>
  
  <pre><code>function unlockModel() {
      $.ajax({
          type: "get",
          url: "main/_unlockmodels"
      }).done(function(data) {
          console.log('well see if your locks are gone', data, '&lt;-- data?')
      });
  }
  </code></pre>
  
  <p>Problem is, wherever I call this function from (in another blueprint) I get the following error</p>
  
  <pre><code>GET http://127.0.0.1:5000/otherblueprint/page/main/_unlockmodels
  </code></pre>
  
  <p>How to specify where I am currently calling from (or other way to fix this)?</p>
  
  <p>I call the function from within my page's <code>javascript</code> like</p>
  
  <pre><code>window.onbeforeunload = unlockModel;
  </code></pre>