given to certain circumstances, I'm forced to keep page settings (Javascript-values) in the session and it has to be done right before leaving the page (I can't use cookies, since "pageSettings" can become quite large and localStorage is not an option yet ;) ). So this is how I tried it. However it seems that when I call the page directly again, the call of "http://blabla.com/bla" happens asynchronous, even though the async-attribute is set (I don't receive the settings of the previous call, but of the one before):
$jQ(document).ready(function () {
$jQ(window).unload(Main.__setSessionValues);
});
var Main = {
pageSettings: {},
__setSessionValues: function __setSessionValues() {
$jQ.ajax({
type: "POST",
async: false,
url: "http://blabla.com/bla",
data: {
pageSettings: Object.toJSON(Main.pageSettings)
}
});
}
};
Does anyone know what the problem might be?
thanks in advance
__setSessionValues. It's a bug in JScript. It's not a big deal for the quoted code (both functions are very small), but it's useful to know in case you're using that pattern for lots of stuff all over. The problem is when you do a named function expression (afunction name() { ... }that you also assign to something at the same time). JScript processes it as a function declaration (creating a function), then processes it again later as a function expression, creating an entirely separate function object. Sadly.