Welcome Guest, Not a member yet? Register   Sign In
Xajax doesn't work with CI ...why?
#1

[eluser]FabD[/eluser]
Hi all,

I try to use xajax with CI and I hac followed this wiki
Xajax Perfect Setup

But nothing happens ...
Here is my controller
Code:
<?php
class Testxajax extends Controller
{

    function Testxajax()
    {
      parent::controller();
            $this->load->library('xajax_core/xajax');
          $this->xajax->registerFunction(array('test_function',&$this,'test_function'));
          $this->xajax->processRequest();
    }
  
    function test_function($number)
    {
              $objResponse = new xajaxResponse();
          $objResponse->Assign("SomeElementId","innerHTML", "Xajax is working. Lets add: ".($number+3));
                  return $objResponse;
    }
    function index()
    {
        $template['xajax_js'] = $this->xajax->getJavascript(base_url().'js/');

        $template['content'] = '<div id="SomeElementId"></div>&lt;input type="button" value="test"&gt;';

        $this->load->view('vtestxajax', $template);
  
    }
  

}
?&gt;

Here is my view :
Code:
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Xajax 0.5 test&lt;/title&gt;
    &lt;?php echo $xajax_js?&gt;
&lt;/head&gt;

&lt;body&gt;
  <h1>&lt;?php echo $content?&gt;</h1>
&lt;/body&gt;
&lt;/html&gt;
Here's my html result
Code:
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Xajax 0.5 test&lt;/title&gt;
    
[removed]
/* &lt;![CDATA[ */
try { if (undefined == xajax.config) xajax.config = {}; } catch (e) { xajax = {}; xajax.config = {}; };
xajax.config.requestURI = "http://belt133374/gerico/index.php?/testxajax";
xajax.config.statusMessages = false;
xajax.config.waitCursor = true;
xajax.config.version = "xajax 0.5";
xajax.config.legacy = false;
xajax.config.defaultMode = "asynchronous";
xajax.config.defaultMethod = "POST";
/* ]]> */
[removed]
[removed][removed]
[removed]
/* &lt;![CDATA[ */
window.setTimeout(
function() {
  var scriptExists = false;
  try { if (xajax.isLoaded) scriptExists = true; }
  catch (e) {}
  if (!scriptExists) {
   alert("Error: the xajax Javascript component could not be included. Perhaps the URL is incorrect?\nURL: http://belt133374/gerico/js/xajax_js/xajax_core.js");
  }
}, 2000);
/* ]]> */
[removed]

[removed]
/* &lt;![CDATA[ */
xajax_test_function = function() { return xajax.request( { xjxfun: 'test_function' }, { parameters: arguments } ); };
/* ]]> */
[removed]
&lt;/head&gt;

&lt;body&gt;
  <h1><div id="SomeElementId"></div>&lt;input type="button" value="test"&gt;&lt;/h1>
&lt;/body&gt;
&lt;/html&gt;

If somebody can show me the light ...

Thanks
Fab
#2

[eluser]Jagar[/eluser]
You have to call the defined function so in your button you would have:
Code:
&lt;input type="button" value="test"&gt;




Theme © iAndrew 2016 - Forum software by © MyBB