Jump to content

how to use jquery with ajax to get data ? (on Zend )


avibitton

Recommended Posts

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.

Link to comment
Share on other sites

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......

Link to comment
Share on other sites

  • 2 months later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.