Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

491
Views
Error : Uncaught TypeError: this.source is not a function

I tried to create Autocomplete using jQuery Ajax. Basically, I want to make autocomplete search with dynamic field added. But while I type in the input field then it gave me this error.

JS Code

$(document).ready(function() {
            var arrayReturn = []
            $.ajax({
                url: "/suppliers",
                async: true,
                dataType: 'json',
                success: function(data) {
                    for (var i = 0; i < data.length; i++) {
                        var id = (data[i].id).toString();
                        arrayReturn.push({'value' : data[i].name, 'data' : id})
                    }
                    printSupplier(arrayReturn);
                }
            });
            function printSupplier(suppliers) {
                $('#purchase_item_search').autocomplete({
                    lookup: suppliers,
                    onSelect: function (result) {
                        $('#autocom-box').html(result.value);
                    }
                });
            }
        });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Problem Solved.

$(document).ready(function() {
            $("#purchase_item_search").on('keyup', function() {
                var arrayReturn = []
                $.ajax({
                    url: "/suppliers",
                    dataType: 'json',
                    success: function(data) {
                        // console.log(data['suppliers'].length);
                        for (var i = 0; i < data['suppliers'].length; i++) {
                            var id = (data['suppliers'][i].id).toString();
                            arrayReturn.push({
                                'value': data['suppliers'][i].name,
                                'data': id
                            })
                        }
                        printSupplier(arrayReturn);
                    }
                });

                function printSupplier(options) {
                    $('#purchase_item_search').autocomplete({
                        source: options,
                        onSelect: function(result) {
                            // $('#autocom-box').html(result.value);
                            console.log(result);
                        }
                    });
                }
            });
        });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!