[eluser]acoldone[/eluser]
I've been having trouble getting xajax to work with codeigniter. I set up a simple test
Code:
<?php
class TestXajax extends Controller {
function TestXajax()
{
parent::Controller();
$this->load->library('Xajax_lib');
$this->xajax = new xajax();
$this->xajax->configure('debug', true);
$this->xajax->registerFunction(array("process_form_data", &$this, "process_form_data"));
$this->xajax->processRequest();
}
function index()
{
$this->load->view('testview','');
}
function process_form_data($someVar)
{
$objResponse = new xajaxResponse();
$objResponse->assign("testDiv", "innerHTML", $someVar);
return $objResponse;
}
}
?>
view
Code:
<html>
<head>
<title>TESTING</title>
<?=isset($this->xajax)?$this->xajax->printJavascript($this->config->item('base_url').'assets/scripts'):""; ?>
</head>
<body>
<div id="testDiv"></div>
<INPUT TYPE="button" value="Test" onclick="xajax_process_form_data('this is a test');return false;">
</body>
</html>
I'm not sure if this is an encoding problem or what. I am testing on a windows machine with apache. I looked for whitespace in the files but couldn't find any. Here is the first part of my
xajax debug output:
Code:
Mon Sep 24 2007 17:52:56 GMT-0700 (Pacific Daylight Time)
ERROR: ResponseReceived: Invalid response XML: The response contains an unexpected tag or text: {data}.
Mon Sep 24 2007 17:52:56 GMT-0700 (Pacific Daylight Time)
RECEIVED [status: 200, size: 112 bytes, time: 110ms]:
[1 space here]<?xml version="1.0" encoding="utf-8" ?>
<xjx>
<cmd n="as" t="testDiv" p="innerHTML">this is a test</cmd>
</xjx>
Here is the javascript error generated in FF:
Code:
Error: xml declaration not at start of external entity
Source File: http://www.wctesting.com/_admin/index.php/testXajax
Line: 1, Column: 2
Source Code:
<?xml version="1.0" encoding="utf-8" ?><xjx><cmd n="as" t="testDiv" p="innerHTML">this is a test</cmd></xjx>-^
There is one space before the <?xml version="1.0" encoding="utf-8" ?> in the xajax debug output (doesn't show up here). Should apache be set to a utf-8 character set? Do all my files have to set to utf-8? I tried changing apache to utf-8 and saving these two files in the same format and it didn't seem to make a difference. Is there any way of stripping out the spaces using a setting in xajax or php itself? Thanks for any help. This has been driving me bonkers.