Missing characters in textbox with onkeyup listener in Firefox
I have a textbox that a user can use to search for items. There is a presenter onkeyup
that searches the database based on what you enter . This works very well in Chrome, but there is a lag in Firefox, and fast typists will see missing characters in the text box. Is this a Firefox issue or is there a workaround for this?
To get a general idea of what I am doing in the code, I have something like this:
Html
<input type="text" onkeyup="makeRequest()">
Js
function makeRequest() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", url + parameters, false);
xmlhttp.send("#");
return xmlhttp.responseText;
}
+3
source to share
1 answer
Maybe make it asynchronous and have some control not to run it if one request is still in progress. In this context, I think it will make more sense and maybe solve your problem in Firefox.
Right now, if someone is typing a lot of emails quickly, you are still sending unnecessary requests.
Like:
//html file
<input type="text" onkeyup="makeRequest()">
//java script file
function makeRequest() {
if(!req_called){
req_called = true;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", url + parameters, true);
xmlhttp.load = function(){
req_called = false;
return xmlhttp.responseText;
}
xmlhttp.send("#");
}
}
+1
source to share