PDA

View Full Version : How to call controller method from html submit button?



swiji2000
9 Mar 2014, 10:26 PM
Hi,

I have one plain html form. i need to call controller method from my html submit button.

Please help me to resolve this issue.

Thanks in Adavance

mdnaveed42
9 Mar 2014, 11:46 PM
Hi,

Added a fiddle: Check this (https://fiddle.sencha.com/fiddle/45g)

Thanks,
Md Naveed
\m/



(https://fiddle.sencha.com/fiddle/45g)

djh1999
11 Mar 2014, 11:09 AM
Hi,

I have one plain html form. i need to call controller method from my html submit button.

Please help me to resolve this issue.

Thanks in Adavance

If you're using extjs, you can use Ext.Ajax.request({url: '/somecontroller/somemethod/', method:'post', data: something}) from any button or div on your page

You can also call mycontainer.getForm().submit({url:...}) which is a little clearer.

And there are a couple of other ways too. Just check the docs for Ext.form.action.Submit.

The controller will have a default method or you can refer to it explicitly. e.g.,
controller = /home
controller + method = /home/users
contoller + method = /home/users/6
You'll have to use the proper action/verb, such as post or get.

Be sure to use a tool such as fiddler or firebug so you can see the actual call and its data. It helps with debugging the calls because you can see the request/response data.