CodeIgniter Forums
using ajax - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: using ajax (/showthread.php?tid=18386)

Pages: 1 2


using ajax - El Forum - 05-04-2009

[eluser]Unknown[/eluser]
how to use ajax with codeigniter?


using ajax - El Forum - 05-04-2009

[eluser]Thorpe Obazee[/eluser]
It's PHP. It works the same way with or without CI.


using ajax - El Forum - 05-05-2009

[eluser]pedro_sland[/eluser]
There is no built-in recommended way. I have tried a few ways but have found it depends on what sort of ajax you are doing. If its to get or set a lot of data instead of html then I create a new method or even controller for it. If its to compliment the html and the action is the same, then I create it in the same method and just use an if to test for ajax to decide whether to load a view or return json.


using ajax - El Forum - 05-05-2009

[eluser]jdfwarrior[/eluser]
[quote author="bargainph" date="1241516717"]It's PHP. It works the same way with or without CI.[/quote]

+1.

CodeIgniter is nothing but a framework. It's still just PHP/HTML/CSS in the end. Whatever way you did ajax before.. It's done the exact same way with CodeIgniter.


using ajax - El Forum - 05-05-2009

[eluser]Jagar[/eluser]
I use xajax toolkit, it's really good and works great. www.xajaxproject.org.

Download the toolkit and put it in the application/libraries/xajax and whenever you want to load it you just do
$this->load->library('xajax'); it depends where it is located, so you may have to change it.

You don't do any javascript stuff, all that is generated by xajax. You should try it.


using ajax - El Forum - 05-05-2009

[eluser]jdfwarrior[/eluser]
jquery ftw.


using ajax - El Forum - 05-05-2009

[eluser]Jagar[/eluser]
Yea Jquery is amazing as well, I'm currently learning that, and it's amazing what you can do with it.


using ajax - El Forum - 05-09-2009

[eluser]sl3dg3hamm3r[/eluser]
[quote author="Jagar" date="1241549091"]Download the toolkit and put it in the application/libraries/xajax and whenever you want to load it you just do
$this->load->library('xajax'); it depends where it is located, so you may have to change it.[/quote]

Hey there

I have troubles loading this library. I renamed xajax.inc.php into xajax.php. When I do

$this->load->library('xajax/xajax');

I would get a:
Fatal error: Cannot redeclare class xajax in [...]\system\application\libraries\xajax\xajax.php on line 59

What am I doing wrong?

Oliver


using ajax - El Forum - 05-09-2009

[eluser]Jagar[/eluser]
When you get that error message, means you are loading it in two places, make sure you have not declared anywhere else, that's how I got mine working.


using ajax - El Forum - 05-10-2009

[eluser]sl3dg3hamm3r[/eluser]
Basically I only tried the small example-snippet which I found somewhere here in the forum:

Code:
function index() {
    
  function test_function($number) {
    $objResponse = new xajaxResponse();
    $objResponse->assign("hello","value", "Xajax is working. Lets add: ".($number+3));
    return $objResponse;
  }

  $this->load->library('xajax/xajax');    
  $this->xajax->registerFunction("test_function");    
  $this->xajax->processRequest();
  $template['xajax_js'] = $this->xajax->getjavascript('../../');
  $template['content'] = '<div id="SomeElementId"></div>&lt;input type="button" value="test"&gt;';
  $this->load->view('template', $template);
}

I don't call this class somewhere else...