How can i pass var selekcija to another function? I need to pass var selekcija to another file (load-epizode.php), but my var is i another function.
var selekcija
$(document).ready(function() {
$('#sezona').change(function() {
selekcija = 1;
selekcija = $('#sezona').val();
console.log(selekcija);
});
$('#epizds').load("/filmovi2/config/load-epizode.php", {
NewSelekcija: selekcija
});
});
Do you want to load content on every 'change' event ? Move the load inside the change event's function
function onSelekcijaChange() {
const selekcija = $('#sezona').val();
console.log(selekcija);
$('#epizds').load("/filmovi2/config/load-epizode.php", {
NewSelekcija: selekcija
});
}
$(document).ready(function() {
onSelekcijaChange();
$('#sezona').change(onSelekcijaChange);
});
Not the best and optimal JS code but I didn't want to change a lot of your code.