Rewrite the component methods to

a) always return the data always as application/json in its headers
b) allow to return as callback when the url request contains a parameter by the name `$callback`
Refactor to make it work with the $callback variable