View Full Version : How do I query a database using AJAX.
Hypertext
16-02-2008, 12:22 AM
A perfect example would be Simons "Find a Habbo" function in invent.no-ip.org/hl2/ thanks..
Zedtu
16-02-2008, 12:26 AM
Easy way: Scriptaculous.
var handlerFunc = function(t) {
alert(t.responseText);
}
var errFunc = function(t) {
alert('Error ' + t.status + ' -- ' + t.statusText);
}
//For an XML response:
var handlerFunc = function(t) {
var xmlDoc = t.responseXML.documentElement;
//Handle data.
}
new Ajax.Request('bla.php', {parameters:'thisvar=true&thatvar=Howdy', onSuccess:handlerFunc, onFailure:errFunc});
bla.php just echos out what you want..
You could also change the handlerFunc to
document.getElementById('mydiv').innerHTML = t.responseText;
Hypertext
16-02-2008, 12:36 AM
So that would work out as querying it without changing the page as bla.php?q=login&x=anotherparam
?? but I could use like a loading image eg windows live mails
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2026 vBulletin Solutions Inc. All rights reserved.