zendframework:Xajax和Zend Framework的整合

  H.E. Pennypacker

  Newbie

  Registered: 2006-11-13

  Posts: 6

  I am using Zend Framework 0.20 and Xajax 0.5.  I am having issues with a simple hello world example.  I just get the generic "The XML response from the server was invalid.." message so it's not helping at all.  I have a very simple hello world.

  Here is my controller code:

  Code: PHP

<?php
HelloWorldController extends Zend_Controller_Action {
 function indexAction
 {
  $xajax = xajax;
  $xajax->registerFunction(.gif' />("doAlert", $this, "doAlert"));
  $xajax->processRequest;
  
  $view = Zend::registry("view");
  $view->title = "Hello World";
  $view->xajaxJs = $xajax->getJavascript("/js/", "xajax.js");
  
  echo $view->render("HelloWorld.php");
 }
 
 function noRouteAction
 {
  echo "No Route!";
 }
 
 function doAlert
 {
  $objResponse = xajaxResponse;
  $objResponse->alert("Whaaaaaaaa");
   $objResponse;
 }
}
?>


  Here is the HTML file (HelloWorld.php):

  Code: PHP

<html>
<head>
<?= $this->xajaxJs; ?>
<title><?= $this->escape($this->title); ?></title>
<link rel="stylesheet" type="text/css" href="/css/jog.css" />
</head>
<body>
<div id="content">
  <h1><?= $this->escape($this->title); ?></h1>
  <input type="button" value="Execute Xajax Alert" _disibledevent=> 0


  I'm just running this off a standard php 5.1.6 wamp ation.  I've tried changing the URI on the xajax instantiation but nothing seems to get this working.  Please, someone help!

  CrazyLegz

  Newbie

  Registered: 2007-02-28

  Posts: 3

  Hi, I had the same problem and found a solution.

  嘿我和你有遇到同样问题并且照了解决思路方法

  I'm using Zend Framework 0.8.0 and xajax 0.2.4

  我使用是Zend Framework 0.8.0 和 xajax 0.2.4

  After examening processRequests method in the xajax I found out that processRequests is calling the getRequestMode method. This method ed -1 wich means $_POST["xajax"] and $_GET["xajax"] are empty.

  If getRequestMode s -1 it exits before is has done something at all. So this means your Ajax call isn't processed.

  In my this was very logical. In my index.php bootstrap file I had the following two lines.

  Zend::register("post", Zend_Filter_Input($_POST));

  Zend::register("get", Zend_Filter_Input($_GET));

  The $_POST and $_GET .gif' />s are to NULL by Zend_Filter_Input.

  So $_POST["xajax"] will never get to processRequests of the xajax .

  You can resolve this by changing the two lines to the following two lines:

  Zend::register("post", Zend_Filter_Input($_POST, false));



  Zend::register("get", Zend_Filter_Input($_GET, false));

  In this way the $_POST and $_GET .gif' />s are left act.

  CtC

  Administrator

  From: Ohio, USA

  Registered: 2006-07-14

  Posts: 1331

  Website

  Thanks for the post!  I've added this to the tips and tricks section of the wiki.

  // Joe



Tags:  zendframework安装 zendframework教程 zendframework代码 zendframework

延伸阅读

最新评论

发表评论