Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6955165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:42:04+00:00 2026-05-27T14:42:04+00:00

$(document).ready(function () { $(#example).autocomplete(https://graph.facebook.com/me/friends?access_token= + accessToken + &callback=?, { width: 250, height: 400, max:

  • 0
 $(document).ready(function () {
          $("#example").autocomplete("https://graph.facebook.com/me/friends?access_token=" + accessToken + "&callback=?", {

               width: 250,
               height: 400,
               max: 8,
               dataType: 'jsonp',
              cacheLength: 10,
               minChars: 1,
               parse: function (data) {
                   var rows = new Array();
                   data = data.data;
                   for (var i = 0; i < data.length; i++) {
                       rows[i] = { data: data[i], value: data[i].name, result: data[i].name };
                   }
                   return rows;
               },
               formatItem: function (data, i, n, value, text, a, b, c, d) {
                   var x = getImage(data.id);
                   return "<div class='test2'><img class='test' width='32px' height='32px' src='" + x + "'></img><span>" + data.name + "</span></div>";
               },

          }
             ).result(function (evnet, item) {
                 alert(item.id);       
            });
     });

     <input type="text" id="example"/>

I am using this code for facebook friends autosuggestion.It works,but its too slow because every time autocomplete function searching data from remote location.

Is there any other way to pass remote data by saving in a variable and passing it to .autocomplete() function.

Later i tried by saving the remote data to a variable , but i can’t pass the variable to autocomplete.

jQuery(document).ready(function () {

var aToken = document.getElementById('aToken').value;
jQuery.getJSON("https://graph.facebook.com/me/friends?access_token="+aToken, function(data) {
    var data = data;
});
    jQuery("#name_inp").autocomplete({
       width: 500,
       height: 200,
   max: 5000,
   source: data,
        dataType: 'jsonp',
        cacheLength: 10,
       minChars: 1,
        parse: function (data) {
            var rows = new Array();
           data = data.data;
            for (var i = 0; i < data.length; i++) {
                rows[i] = { data: data[i], value: data[i].name, result: data[i].name };
           }
             return rows;
         },
        formatItem: function (data, i, n, value, text, a, b, c, d) {
            var x = getImage(data.id);
             return "<div class='test2' onclick='return getId("+data.id+");'><span>" + data.name + "</span></div>";
       },

   }
     )
 });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:42:04+00:00Added an answer on May 27, 2026 at 2:42 pm
    1. You can retrieve the complete friends list and store it locally. Then instead of making remote call do search on local data.
    2. Also set noCache: false it will cache request and will search in cache first
    3. Try with good network connection. 🙂

    EDIT:
    Try this. Here I am storing results in userList variable which can be use as Autocomplete source.

    $(function() {
            userList = null; 
            $.getJSON("https://graph.facebook.com/me/friends", {access_token:access_token,callback:"?"}, function(users) {
                     userList = users;
                 });  
        });     
    

    Or you can try this

    $(function() {
            userList = null; 
            $.getJSON("https://graph.facebook.com/me/friends?access_token=" + accessToken + "&callback=?",function(users) {
                     userList = users;
                 });  
        });     
    

    I never used Facebook API so not sure about which parameters to pass.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do you call function lol() from outside the $(document).ready() for example: $(document).ready(function(){ function
Taking the jQuery framework for example, if you run code like this: $(document).ready(function init()
$(document).ready(function() { $('form#search').bind(submit, function(e){ e.preventDefault(); $('#content').html(''); // Define the callback function function getGeo(jsonData) {
il give an example document.ready(function() { $(#Show).bind(click, function() { var F = Function2(); if
Example: $(document).ready(function(){ height = $('#container-bottom:before').height(); alert(height); }); Alerts null (and I know the value
Here is client Side code: jQuery(document).ready(function(){ jQuery(#list).jqGrid({ url:'example.php', datatype: 'xml', mtype: 'GET', colNames:['Inv No','Date',
For example on a page I have $(document).ready(function() { $('#some-element').click(function() { // do something..
The following example code will load a jqGrid (this code works) ... jQuery(document).ready(function ()
Does a click event always need to be placed inside (document).ready(function() as example below
I am trying this code: <script type=text/javascript> $(document).ready(function() { $('.edit').editable('http://www.example.com/save.php', { indicator : 'Saving...',

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.