Poll: Ajax library? You do not have permission to vote in this poll. |
|||
yes | 18 | 36.73% | |
no | 25 | 51.02% | |
maybe | 6 | 12.24% | |
Total | 49 vote(s) | 100% |
* You voted for this item. | [Show Results] |
[split] Ajax library? |
My personal experience showed that such class is pointless.
The framework should just support different predefined Response types as: html, text, xml, json. Example: PHP Code: $data = array(1=>'ok'); Best VPS Hosting : Digital Ocean
Would be nice if the framework supported RESTful services better out of the box. Like different response types as suggested above and CSRF support for more request types that just POST, as I asked about here http://forum.codeigniter.com/thread-1395.html
I think we could add some support for outputting JSON/Ajax
I have extended output.php already (MY_Output.php) to provide a "nocache" method and json method. Then I only need to use $this->output->json($json); in my controller For the XML's maybe a $this->output->xml($xml); would be nice? As for the RESTful stuff I have also extended the router to provide additional REST methods (maybe not the best approach for everyone but it's a idea) For example class exampleController extends rest_controller { public function dosometingAction() {} /* default GET */ public function dosomethingPostAction() {} public function dosomethingDeleteAction() {} public function dosomethingPutAction() {} } I know the route.php config now supports REST but I'm just not into manually adding 8+ methods for every single controller CRUD = Cx3 Rx1 Ux3 Dx1 minimum . DMyers
Controllers should be able to detect request types... including Ajax requests.
(04-10-2015, 05:05 PM)blocSonic Wrote: Controllers should be able to detect request types... including Ajax requests. How do you suggest the controller detect an AJAX request? HTTP_X_REQUESTED_WITH (the server variable checked by $this->input->is_ajax_request()) represents a non-standard header sent (or not) by the client to indicate an AJAX request, but (especially as a non-standard header), there is no requirement for that header to be present alongside an AJAX request. From the server's perspective, there is otherwise no difference between an AJAX request or a normal request. For this reason, it's largely up to the developer to create a good API for their site and stick to it. If someone sends a non-AJAX request to a method which was designed to only handle AJAX requests, they should be expected to handle the returned data correctly, rather than expecting the server to detect that they didn't use an XmlHttpRequest (and spelling that out brings up the point that the correct return type for an AJAX request isn't set in stone, either). |