CodeIgniter Forums

Full Version: ajax and database access
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I have used aculo (ajax) script and it call php script not connected at all to project, just alone script. I need use CodeIgniter database layer into this script. How to initialize database class?
Thanks for answers and advice.

<select onchange="setSelected()" id="select_state" name="select_state" title="Select state" class="srchselect">
        <option value ="0">Select state</option>
        &lt;?php foreach($states as $item):?&gt;
            <option value ="&lt;?=$item['id'];?&gt;">&lt;?=$item['cat_title'];?&gt;</option>
        &lt;?php endforeach;?&gt;
    &lt;input type="text" name="search_word" id="search_word_id" class="srchinput" &gt;<div id="live_search" style="display:none;border:1px solid black;background-color:white;position:relative;"></div>

        // <![CDATA
            function setSelected() {
                new Ajax.Autocompleter('search_word_id','live_search','',{ tokens: ',', frequency: 0.4, minChars: 2, parameters: 'state='+document.getElementById('select_state').options[document.getElementById('select_state').selectedIndex].value });
        // ]]>

El Forum

I think it would be easier if you would put what ever things you need into another controller or function, and call that instead of an external file. Just a suggestion.