AJAX and other informations

Hi, I’m very new to Yii, and somewhat a beginner in web programming.

I need to display a list of words (taken from a database) and create a search field using AJAX, which changes what words are displayed according to what the user typed in the search field.

Sounds pretty simple, but I’m really lost here, and I read tutorials about Yii and MVC.

First thing, how do I create a new page ? What I did is create a new php file in views/site/pages, and add a link in the menu. Is that how I’m supposed to do it ?

If I want to display data from a database, can I use a view in this new page ? How ? I’m not sure I get how views work. I did create view and controller for the table I’m using with the generator.

And about AJAX, I read while yii has built in classes for ajax, I can still use old ajax.

But I have trouble with the xhr.open method, I don’t know what path I’m supposed to put due to the “page?view=” thing.

Thanks

The views/site/pages directory is intended for static pages. You probably should create an action in a controller, which in turn will use a view belonging to that controller. Perhaps you’ve missed The Definitive Guide to Yii among the tutorials.

The functionality you describe is very similar to what CJuiAutoComplete offers (in a dropdown list, though). There is already many threads on autocomplete in this forum.

/Tommy

Thanks a lot, I managed to do it ;)