avibitton Posted July 16, 2012 Share Posted July 16, 2012 Hi im working on zend framework , i want to get data from database using ajax , than use it for diffrente function of javascript , but i dont know how to use it , and i dont know if i need to open new php page for using the ajax and get methood , how to use the jquery with ajax to get data ?. is it possible also to use jquery with ajax as it is or i need differnte command in zend ? Thx avi. Quote Link to comment https://forums.phpfreaks.com/topic/265748-how-to-use-jquery-with-ajax-to-get-data-on-zend/ Share on other sites More sharing options...
gristoi Posted July 16, 2012 Share Posted July 16, 2012 there are a few choices available to you in the framework: 1) create an aync / ajax controller : you can create an ajax conroller, and in the init method of the controller you disable the view from rendering using: public function init() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(); } then an example method you will call could be /MyajaxController/getmyinfo/var1 public function getmyinfoAction(){ $result = (database array or whatever);//array - stuff from database echo json_encode($result); } 2) read up on zend frameworks context switching. this is the preferable method, as you wont then need a specific ajax controller. the context switching allows you to use your normal controllers, and basically says ' if this call is ajax then return json etc...... Quote Link to comment https://forums.phpfreaks.com/topic/265748-how-to-use-jquery-with-ajax-to-get-data-on-zend/#findComment-1361865 Share on other sites More sharing options...
annaharris Posted September 26, 2012 Share Posted September 26, 2012 Visit this site, it shows you a simple way of using Ajax in Zend Framework : http://www.datawebcoder.com/codeByLanguage/1382/How_to_use_ajax_in_Zend_Framework_.aspx Quote Link to comment https://forums.phpfreaks.com/topic/265748-how-to-use-jquery-with-ajax-to-get-data-on-zend/#findComment-1381011 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.