Thanks for your help. Now it works fine.
I have also added your idea for checking if it is the same string and I also
make the AJAX request only if there are more than 2 chars.
The content requested by AJAX prints a combo box and I want to load a
certain URL when an element from that combo box is chosen.
The problem is that I can't create an event handler to that combo box which
doesn't exist when the page is first loaded.
Is it possible to create the event handler (onchange), and only after this
to create the combo box element using an AJAX request?
Or I would need to first create the combo box in the main page, hide it, and
add only its content from an AJAX request and then show it?
Thanks.
Octavian
From: "Sime Vidas" <sime.vi...@gmail.com>
I did some testing and didn't experience your problems... give us your
code or put a demo online....
Another thing... you should also check if the input value has changed
since the last keyup event, so you don't send the same data if for
example the ENTER or SHIFT keys are pressed.... you can store the
input value for every keyup event and than compare it with the value
of the previous keyup event like this....
$("#term").keyup(function() {
if (($(this).val().length >= 3) && ($(this).data("currentValue") !
== $(this).val())) {
// do AJAX request
}
$(this).data("currentValue", $(this).val());
return false;
});
Also returning false is a nice idea, so that ancestor keyup events
don't trigger this handler....