samedi 18 avril 2015

How to use ajax with blueprints in flask

I would like to define a global ajax function that I will use to unlock models in case a window closes unexpectedly.



@main.route('_unlockmodels)
def unlockmodels():
.. unlock stuff ..
return None


and then the actual ajax



function unlockModel() {
$.ajax({
type: "get",
url: "main/_unlockmodels"
}).done(function(data) {
console.log('well see if your locks are gone', data, '<-- data?')
});
}


Problem is, wherever I call this function from (in another blueprint) I get the following error



GET http://ift.tt/1HF1pCH


How to specify where I am currently calling from (or other way to fix this)?


I call the function from within my page's javascript like



window.onbeforeunload = unlockModel;

Aucun commentaire:

Enregistrer un commentaire