Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/192229-live-search/
Share on other sites

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 :)

Link to comment
https://forums.phpfreaks.com/topic/192229-live-search/#findComment-1012986
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/192229-live-search/#findComment-1013294
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.