PDA

View Full Version : [CLOSED] Call from javascript to Action in Controller



grupoantolin
Jun 02, 2016, 12:26 PM
Hello.

I need to call from a JavaScript to a Controller's Action.

I am trying with


Ext.Ajax.request({url: 'controller/action', param1: value1, param2: value2})

But i can't.

For example, in the next .cshtml:




function AddToCart(id) {
Ext.Ajax.request({url: 'shell/ActionAdd', param1: "10"})
}

X.Button().OnClientClick("AddToCart")



and the controller class ShellController:



public ActionResult ActionAdd()
{
//Do something
return this.Direct();
}


How can i do it?
I know i can use the DirectEvents and the URL.Action(""), but i need to call the action from the javasript.

fabricio.murta
Jun 02, 2016, 3:38 PM
Hello @grupoantolin!

This example shows you how to achieve that: Events - Direct Method Overview (http://mvc4.ext.net/#/Events/DirectMethod/)

grupoantolin
Jun 08, 2016, 2:59 PM
Thanks.

This Works for me.

Regards.