peter-cooper
asked on
Run multiple $.get() from single change event
I am looking for the correct way to run more than 1 $.get() event from a single change event. The code I have posted only returns the first call to loadboxDstrsubcat.php?dstr dept.
I would be grateful if someone could point me in the right direction. I know there is the .when option, but I am still quite green to ajax so any help would be mist welcome. Thanks
I would be grateful if someone could point me in the right direction. I know there is the .when option, but I am still quite green to ajax so any help would be mist welcome. Thanks
$(function() {
$("#dstr_dept").chosen({
width: "260px",
placeholder_text_single: "Select Some Options"
}).change(function() {
$(this).after('<div id="loader"><imgages src="img/loading.gif" alt="loading files" /></div>');
$.get('loadboxDstrsubcat.php?dstrdept=' + $(this).val(), function(data) {
$("#box_dstr").html(data);
$('#loader').slideUp(200, function() {
$(this).remove();
$("#box_dstr").trigger("chosen:updated");
});
});
$(this).after('<div id="loader"><imgages src="img/loading.gif" alt="loading files" /></div>');
$.get('loadboxAdrDstrsubcat.php?dstraddr=' + $(this).val(), function(data) {
$("#dstr_address").html(data);
$('#loader').slideUp(200, function() {
$(this).remove();
$("#dstr_address").trigger("chosen:updated");
});
});
});
});
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
@leakim
Works a treat thanks. Only question I have is, is it ok to have the loader named the way it is? ie, same id? thx
Works a treat thanks. Only question I have is, is it ok to have the loader named the way it is? ie, same id? thx
ASKER
Thank you for your help
Open in new window
If this is a bit nasty, you can try the following - also asynchronous:
Open in new window
Haven't tested these actually, just guessing :)