Welcome Guest, Not a member yet? Register   Sign In
How integrate XAJAX in CI ??
#1

(This post was last modified: 04-02-2015, 11:37 AM by ciadmin.)

[eluser]PoWah[/eluser]
Can someone help with integrating xajax into CI ?
I found article in wiki page about that but it seems to be deprecated, because it is using init/ folder that is deprecated in CI latest versions.

So how shoul the library xajax look like?? Smile
#2

(This post was last modified: 04-02-2015, 11:37 AM by ciadmin.)

[eluser]gunter[/eluser]
I think you can just rename the xajax.inc.php into xajax.php and load it with:
$this->load->library(\'xajax\');

and move on with the example controller...
#3

(This post was last modified: 04-02-2015, 11:37 AM by ciadmin.)

[eluser]esra[/eluser]
Most of the wiki articles mentioning the use of an init file (stored in a application/init/ directory) are left over from the CI 1.3.x series. The init file was used to initialize a library in those versions and CI handles this internally in newer versions. In most cases, you can rename the library file to meet the guidelines for library creation mentioned in the user guide and ignore all mention of the init file.

The absense of the init file creates a problem for more complex libraries with their own directory structures such as ADODB. There is a workaround solution posted on the wiki for handling ADODB.
#4

(This post was last modified: 04-02-2015, 11:38 AM by ciadmin.)

[eluser]PoWah[/eluser]
Ok, library loads, but the example not working Sad
What I do wrong? Here is the code:

application/controllers/testajax.php
Code:
<?php
Class Testajax Extends Controller
{
    function Testajax()
    {
    parent::controller();
    $this->load->library(\"xajax\");
    $this->xajax->registerFunction(array(\'test_function\',&$this,\'test_function\'));
    $this->xajax->processRequests();
    }
    
    function test_function($number)
    {
        $objResponse = new xajaxResponse();
        $objResponse->addAssign(\"SomeElementId\",\"innerHTML\", \"Xajax is working. Lets add: \".($number+3));
        return $objResponse->getXML();
    }
    
    function index()
    {
        $template[\'content\'] = \'<div id=\"SomeElementId\"></div>
                                &lt;input type=\"button\" value=\"test\" onclick=\"xajax_test_function(2);\"&gt;\';

        $this->load->view(\'template\', $template);
    }
}
?&gt;

The view file is very simple with a static link to xajax.js and it only echos $content variable.

Debug message \"xajax_test_function is not defined\".
You can see it in action here: http://laikinas.vai.lt/mobilu.lt/index.php/testajax
#5

(This post was last modified: 04-02-2015, 11:38 AM by ciadmin.)

[eluser]PoWah[/eluser]
I got example working by turning off error_reporting(E_ALL); in CI index.php
I needed to do this because there was a PHP error before returned XML:
severity: notice
undefined variable: sResponse
file: libraries/xajax.php

how can i fix this and turn on error_reporting again ?
#6

(This post was last modified: 04-02-2015, 11:38 AM by ciadmin.)

[eluser]gunter[/eluser]
hm, call the function that produces the error by hand and see what´s wrong...
testajax/test_function/555
#7

(This post was last modified: 04-02-2015, 11:39 AM by ciadmin.)

[eluser]JosGo[/eluser]
[quote author=\"PoWah\" date=\"1182519545\"]how can i fix this and turn on error_reporting again ?[/quote]
There is a small error in Xajax. See thread ellislab.com/forums/viewthread/53574 . I tried it out and it definitely works.
But maybe you have found this thread already.




Theme © iAndrew 2016 - Forum software by © MyBB