SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast laresistance2's Avatar
    Join Date
    May 2011
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with autocomplete of jQuery

    Hello,
    I have a problem with autocomplete of jQuery.
    Here is my code

    Code:
    $('input#recipient').autocomplete ({
        source: function (request, callback) {
           var dataString = {username : request.username};
            $.ajax({
                url: url.root + 'email/',
                data: dataString,
                //cache: false,
                complete: function(xhr, result) {
                   if(result != 'success') return;
                    var response = xhr.responseText;
                    var usernameList = [];
                    $(response).filter('li').each (function() {
                        usernameList.push($(this).text());
                        )};
                        callback(usernameList);
                    }
                });
        }
    });
    Can you tell me what's the problem
    Thank you

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by laresistance2 View Post
    Can you tell me what's the problem
    What is the problem that you're facing?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast laresistance2's Avatar
    Join Date
    May 2011
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My HTML code is
    Code HTML4Strict:
    <!DOCTYPE html>
    <html>
    <head>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/smoothness/jquery-ui.css"/> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
    </head>
    <body>
    <form><input type="text" id="recipient" name="recipient" /></form>
    <script src="username_autocomplete.js"></script>
    </body>
    </html>
    But the JavaScript code does call the server file.
    There must be an error in the javascript code but I have not found...

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by laresistance2 View Post
    There must be an error in the javascript code but I have not found...
    The most obvious problem is the mixed up parenthesis and brace, but there's other more subtle problems such as where the url comes from.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Enthusiast laresistance2's Avatar
    Join Date
    May 2011
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    The most obvious problem is the mixed up parenthesis and brace, but there's other more subtle problems such as where the url comes from.
    Thanks,
    Yes it's
    Code:
      $(response).filter('li').each (function() {
                        usernameList.push($(this).text());
                        });


Tags for this Thread

Bookmarks

Posting Permissions

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