return json for js req, redir for other