Rain Framework is already designed to manage Ajax. It manage the ajax calls separately from the normal calls. It implements an ajax.php script, that turn-on the ajax mode and loads the Ajax manager of the selected controller.
The following URI, calls the Ajax manager of the Blog controller:
example.com/ajax.php/Blog/Action/Parameters/
The blog controller for this example is saved in controller/blog/Blog.php:
class Blog_Controller extends Controller{
function init(){
echo "this is a blog";
}
}
function init(){
echo "this is a blog";
}
}
and the Ajax manager is saved in controller/blog/Blog.Ajax.php:
class Blog_Ajax_Controller extends Controller{
function init(){
echo "this is an ajax call for the blog controller";
}
}
Also in a normal controller you can use the ajax_mode() to immediately print the output of the controller and stop the work-flow of your application.
function init(){
echo "this is an ajax call for the blog controller";
}
}
Also in a normal controller you can use the ajax_mode() to immediately print the output of the controller and stop the work-flow of your application.
