I know this could be similiar with someone, but i'm sure, i'm not yet found the answer here, i just want to call an anonymous function in a variable, which like this
me.req.ref['index']['index'] = function() {
var a, mount;
return {
function: function(fout) {
mount = new loading(fout, "flogin");
mount.start("Login granted, redirecting..");
a = setTimeout(function() {
window.location.href = purl+"profile";
}, 1000);
}
}
};
and i want to call it like this.
var ret;
ret = new me.req.ref[refcode][resp];
ret.function(fout);
but it show an error.
Uncaught TypeError: ret is not a function
i implement this in method loading() and work well, here the code.
function loading(e, code) {
var x = 0;
return {
start: function(str) {
var dot, y;
dot = [".","..","...","...."];
y = 0;
e.style.height = "auto";
e.style.maxHeight = "100%";
e.innerHTML = str+dot[y]+" ("+x+")";
me.time.mount[code] = setInterval(function() {
e.innerHTML = str+dot[y]+" ("+x+")";
x++; y++;
if(y>3) {
y = 0;
}
}, 1000);
},
stop: function() {
clearInterval(me.time.mount[code]);
}
}
}
the way that i call loading() is like this.
mount = new loading(fout, me.time.code["flogin"]);
mount.start("string"); // if i want to start an loading.
mount.stop(); // if i want to shutdown the loading.
any solution? please help. thanks for any correction.
retnowhere in the shown code. Also, should you do so, it would be obvious, asretis supposed to be an object, right?retobject actually has the keyfunctionon it which is bound to a function. When you debug it, is theretobject defined? isret.functiondefined? In your first code block, you are binding tome.req.ref['index']['index'], when you call it arerefcodeandrespequal to'index'?not a function.refcodeandrespis the'index'.retis not supposed to be a function, from your code,retshould be an object, with a property called "function", which is a function. That's why you doret.function(fout);- i don't understand.