Hallo!
Code:
search.js:
Problem: searchResult() wird beim Klicken nicht ausgeführt.
Was habe ich falsch gemacht?
J!M!
Code:
HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript" src="search.js"></script>
</head>
<body>
<form name="search">
<input type="text" name="forename"><input type="text" name="surname">
<input type="button" onClick="searchResult()" value="Suchen">
</form>
<div id="result"></div>
</body>
</html>
HTML:
<script language="JavaScript" type="text/javascript">
<!--
function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert("Dein Browser unterstützt leider nich das XMLHttpRequest-Objekt.");
}
var forename = getElementsByName("forename");
var surname = getElementsbyName("surname");
var searchReq = getXmlHttpRequestObject();
function searchResult(){
if (searchReq.readyState == 4 || searchReq.readyState == 0) {
searchReq.open("POST", 'response.php?forename=' + forename + '&surname=' + surname, true);
searchReq.onreadystatechange = handleResponse;
searchReq.send(null);
}
}
function handleResponse(){
if (searchReq.readyState == 4){
document.getElementById('result').innerHTML = searchReq.responseText;
}
}
//-->
</script>
Problem: searchResult() wird beim Klicken nicht ausgeführt.
Was habe ich falsch gemacht?
J!M!
Zuletzt bearbeitet: