www.webdeveloper.com
Results 1 to 2 of 2

Thread: Help with autocompletion Ajax and jquery

  1. #1
    Join Date
    Apr 2011
    Posts
    1

    Help with autocompletion Ajax and jquery

    Hello,

    I am having problem in the javascript that prints the autocomplete fields. I am passing the array of values to the javascript function to display in the form, but I do not see any dropdown.
    This is the javascript I have used

    The code for passing the array of values to the javascript function is as follows
    Code:
    function get_Names() {
                // Convert the string to the lowercase
                $q = strtolower($this->input->post('q', TRUE));
                print_r($this->input->post());
                if(!$q) {
                    //return;
                }
                $tagnames[] = $this->autocomplete_model->getData();
                
                echo json_encode($tagnames);
    }
    Code:
    <script type="text/javascript">
        $(document).ready(function() {
    	$(function() {
                $( "#tagname" ).autocomplete({
                    source: function(request, response) {
                        $.ajax({
                            url: "<?php echo site_url('generator/get_Names'); ?>",
                            data: {term: $("#tagname").val()},
                            datatype: "json",
                            type:"POST",
                            success: function(data) {
                                response(data);
                            }
                        });
                    },
                    minlenght:2
                });
            });
        });
    </script>

  2. #2
    Join Date
    Apr 2011
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    33
    Well, "minlength" is spelled incorrectly. I'm not JQuery-saavy enough to know if it actually *needs* that parameter or not, but it seems like it'd be worth fixing in order to know

    Do you receive any JS errors in Firebug?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles