Home > Ajax, centOS, Fedora 12, JavaScript, PHP, Unix/Linux, Zend > Zend ajax jquery extjs json xml ajaxcontext

Zend ajax jquery extjs json xml ajaxcontext

How to zend ajax?

1. application/controllers/IndexController.php:

<?php

class IndexController extends Zend_Controller_Action

{

 

 public function init()

 {

 $ajaxContext = $this->_helper->getHelper('AjaxContext');

 // make a file application/views/scripts/index/list.ajax.phtml

 // allowing list.ajax.phtml to be viewed by ajax query.

 $ajaxContext->addActionContext('list', 'html')

 ->initContext(); 

 }

 

 // using the AjaxContext

 public function listAction(){

  echo '2. application/controllers/IndexController.php > IndexController > listAction() > Its me pal!';

 }

  

 public function indexAction()

 {

 }

 public function addAction()

 {

 }

 public function editAction()

 {

 }

 public function delAction()

 {

 }

}




2. application/views/scripts/index/list.ajax.phtml:
<h1><?= _('1. application/views/scripts/index/list.ajax.phtml > I am a ajax view?') ?></h1>
3. it need a ajax request, otherwise it wont show anything. a. make a simple test file with following, so that you can execute it in your browser (ex: http://localhost/mytest/mytest.php )
<!-- jQuery library loaded --> <script src="http://dpaste.de/QuaL/raw/" ></script> <!-- ExtJS or Any other javascript GUI --> <body> <div id ="try" style="position:absolute; top : 50px;left: 50px; width:800px;"></div> </body> <!-- Ajax > zend > load content --> <script> $(document).ready(function(){ // calling zend framework > view $('#try').load('http://localhost:8008/myzf/public/index/list/format/html'); }); </script>
4. Done.
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: