JQuery autocomplete with deleted json data

jQuery(document).ready(function () { var aToken = document.getElementById('aToken').value; jQuery("#name_inp").autocomplete("https://graph.facebook.com/me/friends?access_token="+aToken, { width: 500, height: 200, max: 5000, dataType: 'json', cacheLength: 100, minChars: 1, parse: function (data) { alert(data); var rows = new Array(); data = data.data; console.log(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>"; }, } ) }); 

The above code helps to get the friends list of users from a remote api call. Any help can be used to save json data and search with user request and populate from a stored variable.

to save time and fill out the result accurately.

thanks..

+4
source share
1 answer

The code itself is pretty explanatory :)

Hope this helps!

 jQuery(function ($) { var aToken = $('#aToken').val(); $.get("https://graph.facebook.com/me/friends", {access_token: aToken}, function(result){ var ppl = new Array(); for(var i = 0; i < result.data.length; i++){ ppl[i] = result.data[i].name; } $("#name_inp").autocomplete({ source: ppl, width: 500, height: 200, max: 5000, dataType: 'json', cacheLength: 100, minChars: 1 }); }, 'json'); }); 
+1
source

Source: https://habr.com/ru/post/1386771/


All Articles