I've been using this traditional method to retrieve HTML formatted data through Ajax and insert it into the DOM.
http://localhost/ajax-controller/mobile-view/resource/1/
$mobile_view = new View('mobile-view'); // utilizing mobile view
$mobile_view->data = $this->data_array; // adding data to the view
$this->response->body($mobile_view); // delivering formatted HTML
http://localhost/ajax-controller/web-view/resource/1/
$web_view = new View('web-view'); // utilizing standard web view
$web_view->data = $this->data_array; // adding data to the view
$this->response->body($web_view); // delivering formatted HTML
The question is What would be the RESTful alternative to this?
Should I just fetch JSON data using Ajax?
http://localhost/ajax-controller/resource/1/
$this->response->body(json_encode($this->data_array)); // sending back JSON data
How should I manage view / HTML formatting, is another ajax request needed? Or is there something I'm overlooking?