Error handling now always returns JSON. Removed unnecessary HTML <table> tags.