Could you not just have the Javascript append "&format=json" to the request URLs, then let your request handler deal with things depending on the presence of that parameter?
edit: that's how I plan on doing it, so if it's not good way, let me know so I can avoid any problems :D
EDITED: 4 Nov 2010 21:00 by CAER