i don't know if there is a best way, but you might try something like this:
Code:
$(document).ready(function() {
function clicker(addy, cat){// builds an onclick function that closes clicker's arguments
return function(){
//$('#ulist li').remove();
$('#ulist li').hide("slow");
$.getJSON(addy,
function(data){
for (var i=1, mx=data.length; i < mx; i++){
var dataRow = (data[i]['id']+' '+data[i][cat])
$('<li>' + dataRow + '</li>').appendTo('ul');
}
//alert(data[i]['id']);
});
}
}
$('a#clients').click(clicker("select_from_db.php?table=clients", 'name' ));
$('a#hardware').click(clicker("select_from_db.php?table=hardware",'model' ));
$('a#software').click(clicker("select_from_db.php?table=software", 'manufacturer'));
});
basically i am just using a an extra function as a template to give me a couple keywords to use privately in the onclick.
the vars addy and cat are set at build time, and the inner onclick function remembers those arguments, even though it doesn't accept any arguments of its own.