Hallo,
ich wollte mich auch einmal an AJAX in Verbindung mit JSP ranwagen. Leider hat es nicht auf Anhieb geklappt.
Die Aufrufende Seite ist eigentlich kein Problem. Mit:
Nun weiss ich aber nicht wie ich in der tree_op.jsp die Daten an die Aufrufende Seite als responseText zurücksenden soll
Die tree_op.jsp stellt eine Verbindung zur JavaBeans und einer DB her, und sollte die korrekten daten erhalten. Ich habe aber keine Ahnung, wie ich diese dten (String) an da ursprl. JSP zurückgeben soll...
Für Hilfe wäre ich echt dankbar..
Vielen Dank im Voraus
)
LG,
Hugo
ich wollte mich auch einmal an AJAX in Verbindung mit JSP ranwagen. Leider hat es nicht auf Anhieb geklappt.
Die Aufrufende Seite ist eigentlich kein Problem. Mit:
Code:
function makeGetRequest(wordId) {
//make a connection to the server ... specifying that you intend to make a GET request
//to the server. Specifiy the page name and the URL parameters to send
var buddy = wordId;
http.open('get', 'tree_op.jsp?id='+wordId);
//assign a handler for the response
http.onreadystatechange = processResponse;
//actually send the request to the server
http.send(null);
}
function processResponse() {
//check if the response has been received from the server
if(http.readyState == 4){
//read and assign the response from the server
var response = http.responseText;
//do additional parsing of the response, if needed
//in this case simply assign the response to the contents of the <div> on the page.
document.getElementById('second_row').innerHTML = response;
document.getElementById(buddy).innerHTML += "<br>|";
//If the server returned an error message like a 404 error, that message would be shown within the div tag!!.
//So it may be worth doing some basic error before setting the contents of the <div>
}
Nun weiss ich aber nicht wie ich in der tree_op.jsp die Daten an die Aufrufende Seite als responseText zurücksenden soll
Die tree_op.jsp stellt eine Verbindung zur JavaBeans und einer DB her, und sollte die korrekten daten erhalten. Ich habe aber keine Ahnung, wie ich diese dten (String) an da ursprl. JSP zurückgeben soll...
Für Hilfe wäre ich echt dankbar..
Vielen Dank im Voraus

LG,
Hugo