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

[eluser]GSV[/eluser]
I have used aculo (ajax) script and it call http://127.0.0.1/rmb/db.php 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.

Code:
<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;
    </select>
    &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','http://127.0.0.1/rmb/db.php',{ tokens: ',', frequency: 0.4, minChars: 2, parameters: 'state='+document.getElementById('select_state').options[document.getElementById('select_state').selectedIndex].value });
            }
        // ]]>

El Forum

[eluser]xenon-dev[/eluser]
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.