Kryptix Posted February 16, 2010 Share Posted February 16, 2010 When doing live searches, do you really do a database query for every key they push or do you generate XML every 30 mins or whatever and then search the XML? I run quite a busy site and I can imagine people typing tons of random stuff just to put the server under strain and so on. What do you guys do? Maybe have it detect the server load before offering live search? I want to do it for form registration, checking to see if a username is taken and so on. Quote Link to comment https://forums.phpfreaks.com/topic/192229-live-search/ Share on other sites More sharing options...
RussellReal Posted February 16, 2010 Share Posted February 16, 2010 hello there I'm a runescaper.. or retired anyway, but I play time to time, RussellReal add me if you're interested SIDE NOTE! live search is usually every key or every other key or retriggered after a certain number of milliseconds.. like.. 250 milisecond wait.. even if the guy types like 5000 characters per second.. hes only going to get 4 or so requests in that second.. you gotta figure if someone is typing that fast they know what they want already.. and 4 queries per second if its ajax and returning something light like 40 bytes of data.. and all thats happening is 1 query.. I'm pretty sure you'll be alright Quote Link to comment https://forums.phpfreaks.com/topic/192229-live-search/#findComment-1012986 Share on other sites More sharing options...
Kryptix Posted February 16, 2010 Author Share Posted February 16, 2010 I'm pretty new to all of this, could you show me how to add a time limit? var xmlhttp; function checkCharacter(str) { xmlhttp = GetXmlHttpObject(); document.getElementById("character").innerHTML = "Loading..."; xmlhttp.onreadystatechange = stateChanged; xmlhttp.open("GET", "getuser.php?character=" + str, true); xmlhttp.send(null); } function stateChanged() { if (xmlhttp.readyState == 4) document.getElementById("character").innerHTML = xmlhttp.responseText; } function GetXmlHttpObject() { if (window.XMLHttpRequest) return new XMLHttpRequest(); if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP"); return null; } Also, I want to make various functions like checkAccount() and checkPassword(), do I really need a separate stateChanged() for each of those or is there a way to combine them? Quote Link to comment https://forums.phpfreaks.com/topic/192229-live-search/#findComment-1013294 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.