I have a javascript function which looks like this:
function reloadToolbar() {
        var ids = ["#gs_foo"];
        var parmName = ["foo"];
        for (i = 0; i < ids.length; i++) {
               $.ajax({url:"myurl?parm="+parmName[i],success:function(result){
                 $(ids[i]).html(result);
               }});       
        }
}
However, the above code doesn't work. it doesn't update the id gs_foo. Although, the code below works fine, note the change ($("#gs_foo).html(result))
function reloadToolbar() {
        var ids = ["#gs_foo"];
        var parmName = ["foo"];
        for (i = 0; i < ids.length; i++) {
               $.ajax({url:"myurl?parm="+parmName[i],success:function(result){
                 $("#gs_foo").html(result);
               }});       
        }
}
How can I do this the right way?
 
    