Welcome Guest, Not a member yet? Register   Sign In
Using the Ajax library
#1

[eluser]Unknown[/eluser]
Hi there,

I´m pretty new to CI and am trying to use the ajax library but having some problem with it.

I´m doing a database search upon a change in input text box, once a user types his thing the search should start and it's output should go into one of my divs.

This works and loads the data into the div:
Code:
<?=$this->ajax->link_to_remote("Login", array('url' => base_url().'index.php/foo/bar', 'update' => 'content')); ?>

This does not work when echoed into an onchange event of input type text:
Code:
<?=$this->ajax->observe_field('inputBox', array('url' => base_url().'index.php/lyrics/getLyrics', 'update' => 'content','frequency'=>'1', 'with'=>'search'))?>

And this is the error I get:

A PHP Error was encountered
Severity: Notice
Message: Undefined index: function
Filename: libraries/Ajax.php
Line Number: 247


all help is appreciated Smile
#2

[eluser]jedd[/eluser]
Hi Kaladar and welcome to the CI forums.


[quote author="Kaladar" date="1258493274"]
... trying to use the ajax library ...
[/quote]

When you use or refer to something that isn't in the official [url="/user_guide"]User Guide[/url] it's good to let us know which of the many freely available libraries you happen to be using.

You could save us some time by showing the lines before and after #247 of your Ajax.php file.

In the interim, you might want to read up on [url="http://choosedaily.com/1052/9-ways-to-integrate-ajax-with-codeigniter/"]9 ways to integrate CI with AJAX[/url] - as it has a few tutorials on there showing how to do this interactive / autocompletion stuff.
#3

[eluser]Unknown[/eluser]
Thanks, and sorry for that

I am using this thing below and the Ajax.php file is a part of that package
http://codeigniter.com/wiki/AJAX_for_CodeIgniter/

I´m going to read the link you provided and will hopefully find a better way to use ajax with CI.
#4

[eluser]jedd[/eluser]
[quote author="Kaladar" date="1258500610"]
I am using this thing below and the Ajax.php file is a part of that package
http://codeigniter.com/wiki/AJAX_for_CodeIgniter/
[/quote]

Ahh, cool. It's a bit regrettable, but sometimes you need to check the freshness of pages in the wiki (look at the history for the page). This one was last updated in the middle of last year. Now, most of the time information doesn't have a use-by date, but there are gradual changes to the CI core - most of them backwards-compatible of course - but you sometimes just get things that will appear to stop working, simply because they were written for an earlier version of CI.

Having said that, if you're using jQuery rather than raw JavaScript, you may also want to check out [url="/wiki/jQuery_Ajax_Helper/"]Brodie's AJAX Helper[/url]. I'm not hugely au fait with javascript or indeed jquery, so if you still have problems be sure to post again - providing lots of detailed information! - and someone a bit more knowledgeable will probably pop up and help.
#5

[eluser]CI_avatar[/eluser]
if you have problem using ajax for codeigniter, you can may use ajax or javascript (e.g. jquery) in a usual way. <javascript> + <codeigniter>




Theme © iAndrew 2016 - Forum software by © MyBB