Made file browser work in JSON too.

Also some minor preliminary stuffs for moving most of the ajax requests
into background, so they're centralised.