!!! Listing 1: Prototype: Ajax.Request new Ajax.Request('/code/WS/getFortuneCookieWS/python/', { method : 'post', postBody : 'mimeType=text/xml', onSuccess : showXmlFortuneMessage, onFailure : function(resp) { alert('Fehler: ' + resp.statusText); }, onException : function(resp, exception) { alert('Ausnahme ' + exception); } }); !!! Listing 2: Prototype: Ajax.Updater Ajaxbuch.de: Prototype-Glückskeks

Ajax-Glückskeks

Glückskeks-Botschaft:

!!! Listing 3: cookieHandler { ajaxUpdate: function(responseXML) { var cookieMessage = responseXML.documentElement.firstChild.nodeValue; document.getElementById('fortuneMessage').firstChild.nodevalue = cookieMessage; // Die letzte Anweisung setzt voraus, dass das firstChild ein // vorhandener Textknoten ist. } } !!! Listing 4: function showCookie(resp) { var cookieMessage = resp.responseXML.documentElement.firstChild.nodeValue; document.getElementById('fortuneMessage').firstChild.nodevalue = cookieMessage; } responseObject.addCallback(showCookie); !!! Listing 5: var dsFortuneCookie = new Spry.Data.XMLDataSet("/code/WS/getFortuneCookieWS/", "/message", { method: "POST", postData: "mimeType=text/xml", headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}});