开发者

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')
               ); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜