Ajax Call Not Firing After 5 Keystrokes
Why does this require more than 5 keystrokes before firing? $( document ).ready(function() { $('#zipcode').on('keyup', function(event) { // keyup function if(this.value.len
Solution 1:
$(document).ready(function() {
splitted = []; // Inialization empty array
$("#zipcode").autocomplete({
source: splitted
}); //Inialization for enabling the feature of Auto-complete
$("#zipcode").keyup(function(event) {
if (this.value.length == 5) {
var zicpcode = $("#zipcode").val();
$.ajax({
url: "http://pages.em.essilorusa.com/page.aspx?QS=773ed3059447707d2a7242227e94bba8efcc7ce6da09facd&zip=" + zicpcode,
type: "get", //send it through get method
async: false,
success: function(results) {
var res = results.substring((results.indexOf("<rs1>") + 5), results.indexOf("</rs1>"));
var splitted = res.split("|");
$("#zipcode").autocomplete({
source: splitted
});
},
});
}
});
});
Post a Comment for "Ajax Call Not Firing After 5 Keystrokes"