CodeIgniter Forums
ajax and database access - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: ajax and database access (/showthread.php?tid=2853)



ajax and database access - El Forum - 08-28-2007

[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 });
            }
        // ]]>



ajax and database access - El Forum - 08-28-2007

[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.