fix #4149

Return json for ajax requests.