I'm implementing some Ajax to change page content using a web service, and I'm stumped.
Here's the web service code: <% response.setContentType("application/x-json") def success = "Successful Ajax Web Service call!" %> { "rdoc": "<%=success%>" } Here's the javascript Ajax call: <!-- AJAX Web Service Call --> <script type="text/javascript"> function getRenderedDoc() { window.alert("Function Called"); new Ajax.Request( // Here we make the asynchronous call to our previously created web service. // Note that we are using the XWiki API from velocity to compute the exact URL we want to hit. // This is possible since the entire page will be evaluated by the velocity engine before being sent to // the client from which this javascript function will be executed. // We precise the number of entries we want to retrieve using the limit parameter. The second parameter, // "xpage=plain" is mandatory, this force XWiki to render the called document with the "plain.vm" velocity // template, thus not returning the whole skin. If we forget this parameter, we will not receive a valid JSON // and our client will not work. "/1.8/bin/view/Main/WebService?xpage=plain", { method: 'get', onSuccess: function(transport) { // first, we evaluate the JSON result to make it manipulable as javascript objects var res = eval( '(' + transport.responseText + ')' ); var rendcontent = res.rdoc; var rdiv = document.getElementById("div_Space_Rhodopsin"); while( rdiv.childNodes.length >= 1 ) { rdiv.removeChild( rdiv.firstChild ); } var pTag = document.createElement("p"); pTag.innerHTML = rendcontent; rdiv.appendChild(pTag); } } ); } </script> I call the function from an anchor tag: <a href="javascript:getRenderedDoc()">Test Ajax</a> The alert is displayed, but I'm not seeing any update on my page. All of the DOM manipulations have been independently verified with text literals outside of the Ajax.Request. Thanks. Dan Svoboda _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users