cleaning up javascript code for ajax delete call