Welcome Guest, Not a member yet? Register   Sign In
At my wit's end with Ajax.Updater
#2

[eluser]myerman[/eluser]
I've reworked a few things (actually a TON of things) and finally resorted to (in some cases) literally copying and pasting Derek Allard's javascript onto my stuff, still with zero effect. Here is the new stuff. I can't believe how long this is taking--it took 15 minutes to code up the PHP, and approximately 11 hours and counting on this crazy Javascript crap.

You'll notice that I have a controller function called getbar()...this I put in just to make sure my brain was working....I can go to http://www.tripledogs.com/ndaclub/getbar/texas and get back a list of bars whose name contain "texas". Same model function as with the form, but that doesn't work:

http://www.tripledogs.com/ndaclub/index



CONTROLLER
Code:
function index(){
        $data['title'] = "NDA Club - Find a Bar!";
        $this->load->vars($data);
        $this->load->view('_ndaclub');
    }
    
    function findbar(){
        $searchterm = $this->input->post('searchterm');
        echo $this->MBars->search($searchterm);
    
    
    }
    
    function getbar($term){
        echo $this->MBars->search($term);
    }


MODEL
Code:
function search($term){
        $this->db->select('name,phone');
        $this->db->like('name',$term);
        $Q = $this->db->get('bars');
    
        if ($Q->num_rows() > 0){
            $string = "<ul>";
            foreach ($Q->result() as $row){
                $string .= "<li><b>".$row->name."</b> - ".$row->phone."</li>\n";
            }
            $string .= "</ul>";
            return $string;
        }else{
            return "No bars found!";
        }
    
    }


VIEW
Code:
&lt;html&gt;
&lt;head&gt;
[removed]
//&lt;![CDATA[
base_url = '&lt;?php echo base_url();?&gt;';
//]]>
[removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
&lt;/head&gt;
&lt;body class="oneColFixCtr"&gt;

<div id="container">
  <div id="mainContent">
    <h1>&lt;?php echo $title;?&gt;</h1>
    
    
    &lt;form id="searchform" method="post" action="&lt;?php echo site_url('ndaclub/findbar');?&gt;"&gt;
    <div>
        <label for="search_term">Search by bar name</label>
        &lt;input type="text" name="search_term" id="search_term" /&gt;
        &lt;input type="submit" value="search" id="search_button" /&gt;
        <div id="autocomplete_choices"></div>
    </div>
    &lt;/form&gt;
    <div id="search_results" style="display:none;">
    
    </div>    
    
    


    &lt;!-- end #mainContent --&gt;</div>
&lt;!-- end #container --&gt;</div>
&lt;/body&gt;
&lt;/html&gt;


JAVASCRIPT

Code:
window.onload = function () {
    new Ajax.Autocompleter("search_term", "autocomplete_choices", base_url+"ndaclub/findbar/", {});

    $('searchform').onsubmit = function () {
        inline_results();
        return false;    
    }
}

function inline_results() {
    new Ajax.Updater ('search_results', base_url+'ndaclub/findbar/', {method:'post', postBody:'seachterm='+$F('search_term')});
    new Effect.Appear('search_results', {duration:1});

}


Messages In This Thread
At my wit's end with Ajax.Updater - by El Forum - 07-30-2008, 12:50 AM
At my wit's end with Ajax.Updater - by El Forum - 07-30-2008, 10:20 AM
At my wit's end with Ajax.Updater - by El Forum - 07-30-2008, 12:00 PM
At my wit's end with Ajax.Updater - by El Forum - 07-30-2008, 01:45 PM
At my wit's end with Ajax.Updater - by El Forum - 07-30-2008, 03:17 PM
At my wit's end with Ajax.Updater - by El Forum - 07-30-2008, 04:13 PM
At my wit's end with Ajax.Updater - by El Forum - 07-30-2008, 09:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB