I have a dialog, in the dialog are dynamic buttons. In every button, a $.get() is generated.
The path to the file is partly variable, and the function (which will be executed on success) is variable too.
But I can't get it to work. The console says that the variables are undefined.
I know why, because it's in a function. But I set the variables globally.
Can anybody explain me how I can get these variables to work?
I will provide my source code so you can see what I mean.
The source code
var dialog_buttons = {};
for(var i=0;i<socialMediaServ.length;i++)
{
dialog_buttons["Upload naar "+socialMediaServ[i]]= function()
{
$("#wait-dialog").dialog(
{
modal: true,
resizable: false,
draggable: false,
width:305,
height:125,
my:'center',
at:'center',
open: function(){}
});
$.get("../includes/social/"+socialMediaServ[i]+"/upload.php",{functie: "checkUser", fotonaam: fotoNaam}, window['users_'+socialMediaServ[i]+'_check'], 'json');
}
};
dialog_buttons["Sluiten"]= function()
{
$(this).dialog("close");
};
$("#dialog-foto").dialog("option", "buttons", dialog_buttons);
$("#dialog-foto").dialog("open");
The variable socialMediaServ is set on the top of my page. socialMediaServ is an array with: Facebook,Twitter
Many thanks in advance!