Okay lets begin,
I have created an ajax namespace in javascript that just made it easier to remember what values needed to be inserted in-order to get it to work.
(function (ns) {
ns.type = "POST";
ns.url = "/";
ns.data = {};
ns.success = function() {};
ns.send = function() {
$.ajax({
type: ns.type,
url: ns.url,
data: ns.data,
success: ns.success()
});
}
}(fps.ajax));
to make use of it I do the following
var ajax = fps.ajax;
ajax.url = "/credit/getBalance";
ajax.type = "GET";
ajax.success = function (e) {
navCredits.text(navCredits.text().f(e));
};
ajax.send();
now the problem I'm having is my success function.
I pass it a varible that I want my ajax function to use as it's return data but it's not happening in that way.
My understanding of this is that it's (e) not declaired where the success function is being set, hence why I'll get an undefined value.
My question is, is there a way to pass a function with a "parameter" that the function should use for it's own functions value?
I don't feel like I'm explaining very well but hopefully there's enough code there to help you understand what I'm trying to achieve.
Kind regards
f()inside the success function