CodeIgniter Forums
[Solved] CI + XAJAX Global Functions - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: [Solved] CI + XAJAX Global Functions (/showthread.php?tid=10659)

Pages: 1 2


[Solved] CI + XAJAX Global Functions - El Forum - 10-11-2008

[eluser]aslamdoctor[/eluser]
Can you please post all the steps you followed to make xajax functions global???

It is highly required solution.


[Solved] CI + XAJAX Global Functions - El Forum - 10-12-2008

[eluser]LifeSteala[/eluser]
Sure - here is how I did it.

In MY_Controller put your ajax functions in it - like so:

Code:
function getUserAjax()
{
// Code to get user info via Ajax
}

function getCountries()
{
// Code to get a list of countries
}

These two functions are your Ajax functions. In MY_Controller you also need:

Code:
function loadAjax()
{
$this->xajax->registerFunction(array('getUserAjax',&$this,'getUserAjax'));        
$this->xajax->registerFunction(array('getCountries',&$this,'getCountries'));
}

In your controller you then do this:

Code:
$this->loadAjax();
$data['xajax_js'] = $this->xajax->getJavascript(base_url());
$this->xajax->processRequest();

Viola, you have a global ajax function.

Hope this helps.

Good Luck!


[Solved] CI + XAJAX Global Functions - El Forum - 10-12-2008

[eluser]aslamdoctor[/eluser]
thanks for that


[Solved] CI + XAJAX Global Functions - El Forum - 10-12-2008

[eluser]LifeSteala[/eluser]
Most welcome.. Smile