Call action method in jQuery with Kohana php framework
In Asp.Net MVC I have used helpers to specify paths to actions and controllers, like this:
var url = "@Url.Action("OrderAction", "OrderController")";
$.post(url, { name: name, prodno: prodno }, function(data) {
//Do stuff
});
Now I'm trying to learn Kohana and php, and I was wondering if there is a similar way to do it there? Or how else do I call a specific action method in a controller to post to it?
EDIT: Here's the routing in bootstrap.php if it helps:
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'home',
'action' => 'index',
));
开发者_高级运维
You can use Reverse Routing to transform a route and optional arguments to the link...
echo Route::url('route_name', array('optional' => 'arguments'));
...could you provide an example of how I would use this to produce the call to OrderAction method in OrderController controller[?]
echo Route::url('default',
array('controller' => 'Order', 'action' => 'Action')
);
精彩评论