Reordered html/json handling in controller