How to make array show only 5 attributes?

Need to get data from an array displayed only when the search for him. Not sure what this code is responsible for it. No need to load all the data or to limit 5.

// Attributes
 'delay': 250,
 'source': function(request, response) {
 url: 'index.php?route=seller/account-product/jxAutocompleteAttributes&filter_name=' + encodeURIComponent(request),
 dataType: 'json',
 success: function(json) {
 var existing_attrs = [];
 $.map($(document).find('.mm_attribute').not('.ffSample'), function(attribute_row) {

 response($.map(json, function(item) {
 if($.inArray( existing_attrs) == -1) {
 return {
 category: item.attribute_group,
 value: item.attribute_id
 'select': function(item) {
 var newAttr = $(this).parents('#mm_product_attributes').find('.form-group:last');
April 19th 20 at 11:59
1 answer
April 19th 20 at 12:01
Try to localize the problem clearly, because if You are not sure that this is the code that needs to be repaired, it meets even harder to guess where the problem is.
Now you can understand that in the ajax success handler data come from the argument json, and this json is processed in the function $.map. Means in advance it is necessary to leave from json first five items and then pass them to the map. Ideally, the five elements necessary to give from the backend and not be at the level of the frontend.
Use the debugging capabilities of js scripts (console.log, debugger)

Find more questions by tags jQuery