|
|
|
#*****************************************************************#
# DATENBANK: #
# AJAX ( Asynchronous Javascript and XML ) #
# Beispiel #
#*****************************************************************#
########## HTML-Bereich ##########
# JavaScript
<script language="JavaScript" type="text/JavaScript">
<!--
function verbindungsobjekt() {
var vo;
try { // MSIE 6
vo = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try { // MSIE 5
vo = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) { // Mozilla
vo = new XMLHttpRequest();
}
}
return vo;
}
var http = verbindungsobjekt();
var alt = "";
function senden(action) {
if(alt != action) {
alt = action;
action = escape(action);
http.open("get", "antwort.pl?"+action);
http.onreadystatechange = handleResponse;
http.send(null);
}
}
function handleResponse() {
if(http.readyState == 4){
if(http.responseText.indexOf("<br>") == -1) {
document.getElementById("ausgabe").innerHTML = "";
} else {
document.getElementById("ausgabe").innerHTML = http.responseText;
}
}
}
//-->
</script>
# Formular
<form name="wm">
<input size="25" maxlength="100" autocomplete="off" name="SUCHE"
onKeyUp="senden(document.wm.SUCHE.value);" >
<br>
<div id="ausgabe"> </div>
</form>
########### Perl-Bereich ##########
use URI::Escape;
my $VAR = $ENV{'QUERY_STRING'};
# URL decoden
$VAR = uri_unescape($VAR);
my $content = '';
# ... DATENBANK ABFRAGE ... #
print "content-type: text/html\n\n";
print '<DIV style="z-index:1;padding:5px; border:1px solid;height:250px;
width=250px; overflow:auto; text-align:left;">';
print $content;
print '</DIV>';
|