Reputation: 175
I know that stackoverflow is not to do my job, for that I ask for generics advices
http://www.imobiliare.ro/sugestii/huned
, I need a javascript function, that is continuous read and send information from input text to URL.E.g
I have :"http://www.imobiliare.ro/sugestii/huned"+ T , T value from input, Information is pass to URL and generate a JSON, after that http://www.imobiliare.ro/sugestii/huned+T+I, TI values from input.
Hard part for me is how to send continuous that information to url without press a submit button, something like every time I pass a value in input text, is read and send automaticali to URL and make a request
I can't use any existing lib.
Upvotes: 2
Views: 1015
Reputation: 2228
Here is some starting points for you, which you should already know if you took a task which says "do not use any libraries". Autocomplete "without using any libraries" is wrong design requirement and a waste of time in almost all cases imaginable.
That's all. You absolutely do not need any "continuous" checking, only key presses.
For "continuous" checking you should use setTimeout
and setInterval
functions.
EDIT
Here is JsFiddle with the crude solution showing both of my points: you attach an event listener to the text input and then (with proper debouncing mechanics!) on key presses you send a request to your backend API. Everything else is up to your imagination. Usually results are returned into a dropdown list, but I certainly would not reimplement that from scratch.
Upvotes: 2
Reputation: 1
this might help you Building an Autocomplete from scratch with javascript
Upvotes: 0