开发者

How do call the controller and action from javascript in Zend framework

开发者 https://www.devze.com 2023-01-10 15:49 出处:网络
How docall the Controller/actionin Zend framework from Javascriptsuch as if(a==b){ } else{ document.myform.action=\"/fz/controllername/actionname\"

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/controll开发者_运维百科ers/


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.


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" }


f(a==b){ } 
    else{ 
         document.myform.action="/controllername/actionname" 
    }
0

精彩评论

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