function zoekFunction(soort) { var zoek = document.getElementById("zoek").value; if (zoek === "") { document.getElementById("zoekdiv").innerHTML = ""; document.getElementById("zoekdiv").style.border = ""; return; } if (zoek === document.getElementById("zoek").alt) { return; } document.getElementById("zoek").alt = zoek; var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState===4) { document.getElementById("zoekdiv").innerHTML = xmlHttp.responseText; document.getElementById("zoekdiv").style.border = "thin solid rgb(0,0,0)"; } else if (document.getElementById("zoekdiv").innerHTML === "") { document.getElementById("zoekdiv").innerHTML = "Bezig met zoeken..."; document.getElementById("zoekdiv").style.border = "thin solid rgb(0,0,0)"; } } xmlHttp.open("GET","/ajax/zoek/"+soort+"/"+zoek,true); xmlHttp.send(null); } /* function zoekFunction(soort, timeout, t) { var date = new Date(); var tijd = date.getTime(); if (timeout !== 1) { document.getElementById("tijd").value = tijd; if (soort === 'movies') { setTimeout("zoekFunction('movies', 1, tijd)",0); //Oude timeout was 2000ms } else if (soort === 'games') { setTimeout("zoekFunction('games', 1, tijd)",0); } else if (soort === 'covers') { setTimeout("zoekFunction('covers', 1, tijd)",0); } } else if (document.getElementById("tijd").value > t) { return; } else { ajaxFunction(soort); } } */