views:

91

answers:

2

How do call the Controller/action in Zend framework from Javascript such as if(a==b){ } else{ document.myform.action="/fz/controllername/actionname" }

My controllers are located in the src/controllers/

A: 

Just call it like any other urls. If I had a news controller and wanted to post there from a form I would just set the form`s action to: '/news' and be done with it.

To expand on this a bit if I had a post action in my news controller I would set

if(a==b){ } else{ document.myform.action="/news/post" }
Iznogood
Dont we need extension as php
Someone
What? aaah. no not at all. In a Zf app everything goes thru index.php and the right controller with the right view are called.
Iznogood
Also you might want to look up modrewrite and routing in zend framework to help you understand.
Iznogood
+1  A: 

Since a JS Call is just a regular web call you do it the same way you would access any other Action of your Project, the question is how you handle the output.

Hannes