«
»
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
class HelloWorldController extends Zend_Controller_Action {
function indexAction()
{
$xajax = new xajax();
$xajax->registerFunction(array("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 = new xajaxResponse();
$objResponse->alert("Whaaaaaaaa");
return $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" onClick="xajax_doAlert();" />
</div>
</body>
</html>
And here is a view source of the rendered html file, all looks good:
Code: PHP
<html>
<head>
<script type="text/javascript"><!--
var xajaxConfig = {
requestURI: "http://127.0.0.1/HelloWorld",
debug: false,
statusMessages: false,
waitCursor: true,
version: "xajax 0.5 Beta 1",
legacy: false
};
var xajaxLoaded=false;
function xajax_doAlert(){return xajax.call("doAlert", {parameters: arguments});}
function xajax_doUpdateDiv(){return xajax.call("doUpdateDiv", {parameters: arguments});}
--></script>
<script type="text/javascript" src="/js/xajax.js"></script>
<script type="text/javascript"><!--
window.setTimeout(function () { if (!xajaxLoaded) { alert('Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?nURL: /js/xajax.js'); } }, 6000);
--></script>
<title>Hello World</title>
<link rel="stylesheet" type="text/css" href="/css/jog.css" />
</head>
<body>
<div id="content">
<h1>Hello World</h1>
<input type="button" value="Execute Xajax Alert" onClick="xajax_doAlert();" />
</div>
</body>
</html>
Finally, a print_r of