[SOLVED] Autocomplete External JSON

What is the error in my code that does not extract the data from my URL?

self.autocompleteDropdownAjax = app.autocomplete.create({
          inputEl: '#autocomplete-dropdown-ajax',
          openIn: 'dropdown',
          preloader: true, 
          valueProperty: 'id', //object's "value" property name
          textProperty:  'name', //object's "text" property name
          limit: 3, //limit to 20 results
          dropdownPlaceholderText: 'Seleccionar Cliente...',
          source: function (query, render) {
             
            var autocomplete = this;
            var results = [];
            if (query.length === 0) {
              render(results); 
              return;
            }
            // Show Preloader
            autocomplete.preloaderShow();
            // Do Ajax request to Autocomplete data
            app.request({
              url: 'http://www.grupobennetts.com.mx/VIC/clientes_aut.php',
              method: 'GET',
              dataType: 'json',
              //send "query" to server. Useful in case you generate response dynamically
              data: {
                query: query,
              },
              success: function (data) {
                // Find matched items
                for (var i = 0; i < data.length; i++) {
                  if (data[i].name.toLowerCase().indexOf(query.toLowerCase()) >= 0) {
                     results.push(data[i]);  
                  }
                }
                // Hide Preoloader
                autocomplete.preloaderHide();
                // Render items by passing array with result items
                render(results);
                
              }
            });
            
          }
        });

it works correctly if it directs to a local file but does not work to an exeternal link

1 Like

Hi, I’m resolved … the problem was that the JSON had names with characters like “ñ” … see you

2 Likes