Way to simplify this?
Way to simplify this?
So, I've got this code working....however, it just looks awfully verbose. I'm sure there's a way to refactor but not coming up with anything that works. Suggestions?
- $("#search").click(function(){
$("#available").remove();
if ($('#district-search').attr('checked')) {
$.get("urlhere",
function(data){
$('#select-holder').html(data);
});
}
if ($('#teacher-search').attr('checked')) {
var fromstaffgroup = $("#staff-group option:selected").val();
var fromhighschool = $("#staff-hs option:selected").val();
$.get("differenturlhere" + fromstaffgroup + "&staff-hs=" + fromhighschool + "",
function(data){
$('#select-holder').html(data);
});
}
if ($('#recipients').attr('checked')) {
var fromreports = $("#staff-report option:selected").val();
$.get("anotherdifferenturl" + fromreports + "",
function(data){
$('#select-holder').html(data);
});
}
});
});