'Creating a simple Javascript function for pushing a string or int written in the texfield for an autocomplete

As the title says I need this function for an autocomplete and I get an error saying that "data.split is not a function". My code is:

        var url = _url + '?module=FeedManagement&action=searchProducts';

    $("input#autocomplete").autocomplete(url, {
        width:400,
        max:200,
        minChars: 3,
        dataType:'json',
        selectFirst:true,
        parse: function(products){
            var parsedProducts = [];
            $.each(products, function(index, product) {
                if (product.isString(index)) {
                    parsedProducts.push({ data : product, value: 'y', result : product.product_name});
                    return parsedProducts;
                }

                if (product.isInteger(index)) {
                    parsedProducts.push({ data : product, value: 'y', result : product.sku});
                    return parsedProducts;
                }

            });

        }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source