views:

45

answers:

2

Hi guys,

I'm trying to implement a search for my project , but i can't figure it out how to use ajax and get data to the view, can some one help me with this?

(this is my first project using codeignter and jquery)

regards, Rangana

+1  A: 

Here's a nice tutorial: http://aext.net/2009/10/codeigniter-and-jquery-real-live-search-with-pagination/

Otar
+3  A: 

Here's a quick overview:

  1. You need to create an input box (obviously).
  2. On your js file, you give that input an event (keypress or anything you want) and when the event triggered you send an ajax post request to your controller method.
  3. On your controller method you read the post request, then do a DB search, you return the result to your js by 'echoing' the DB search result using your preferred format (JSON, xml, etc).
  4. You process the result on your js file using callback.
leonardys