Reputation: 91
I have a select in my form. When I change it "change function" assign that value to vardir variable. I want to send this variable into uploadFile scope but it doesn't recognize variable(empty) but afterUploadAll function alert show true value of the variable.
How can I send a variable into scope? Thank you
var vardir = "";
$("#galeri").live("change",function(event) {
if ( $("#galeri").val() != '') {
$("#yukletr").show("slow");
vardir = $("#galeri").val();
}
else
$("#yukletr").hide("slow");
});
$("#fileuploader").uploadFile({
url:"upload.php",
multiple:true,
method:'POST',
formData: { dir: vardir },
allowedTypes : "png,jpeg,jpg,gif",
afterUploadAll:function()
{
alert(vardir);
}
});
Upvotes: 1
Views: 102
Reputation: 91
I solved the issue. there is a dynamicFormData function like;
dynamicFormData: function() {
var data ={ dir: $("#galeri").val() }
return data;
}
Upvotes: 2
Reputation: 10410
You should call the upload function right after the change event is triggered:
var vardir = "";
$("#galeri").live("change",function(event) {
if ( $("#galeri").val() != '') {
$("#yukletr").show("slow");
vardir = $("#galeri").val();
// relocated here!
$("#fileuploader").uploadFile({
url:"upload.php",
multiple:true,
method:'POST',
formData: { dir: vardir },
allowedTypes : "png,jpeg,jpg,gif",
afterUploadAll:function()
{
alert(vardir);
}
});
}
else
$("#yukletr").hide("slow");
});
Upvotes: 0