Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External source data #23

Open
VladimirVecera opened this issue Mar 20, 2021 · 2 comments
Open

External source data #23

VladimirVecera opened this issue Mar 20, 2021 · 2 comments

Comments

@VladimirVecera
Copy link

VladimirVecera commented Mar 20, 2021

How can I get data written in autocomplete and make source data from an external file?

$('#myAutocomplete').on('input keyup', function() {
    var query = $(this).val();
    if (query.length > 2)
    {
        $.ajax({
            url:"/search.php",
            data: query,            
            dataType:"json",
            cache: false,
            processData:false,
            type:"POST",
            success: function (data) {
                $('#myAutocomplete').autocomplete({
                    source: data,
                    maximumItems: 10,
                    treshold: 2      
                });
               }
        });
    }   

});
@Honatas
Copy link
Owner

Honatas commented Mar 22, 2021

Hi @VladimirVecera! I didn't understand your question ... isn't this code working as expected? Have in mind that /search.php must return a JSON object in the body for it to work properly.

@HenryKim2022
Copy link

He mean the 'src'...

<script>
	$('#search').autocomplete({
		source: src,
		onSelectItem: onSelectItem,
		highlightClass: 'text-danger',
		treshold: 2,
	});
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants