Or you could just call eval(ajax.responseText). (*Chris*)
On 11/28/06, Frank W. Zammetti <[EMAIL PROTECTED]> wrote:
Hi Adam, If your doing straight AJAX yourself, i.e., directly interacting with the XMLHttpRequest object, this won't execute script for you automatically. In fact, it won't do much of anything for you automatially, aside from parsing XML if that's your return type. Otherwise, it's just text to the object and you'll have to execute scripts yourself. Another poster gave you some info if your using S2, but I'm guessing by your description your using S1. In that case, continue reading! :) The AjaxParts Taglib (APT) in Java Web Parts (JWP) takes care of this for you... you can certainly switch over to using APT, but if you just want some code to execute scripts, take a look here: http://javawebparts.cvs.sourceforge.net/javawebparts/javawebparts/WEB-INF/src/javawebparts/ajaxparts/taglib/resources/AjaxPartsTaglib.js?view=markup Down around line 313 you'll find the execScripts() function... simply yank that out and use it on the responseText from XMLHttpRequest and you'll be good to go. If you are interested in looking at APT, here's a link: http://javawebparts.sourceforge.net/javadocs/javawebparts/ajaxparts/taglib/package-summary.html And for JWP in general: http://javawebparts.sourceforge.net Hth, Frank -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM/Yahoo: fzammetti MSN: [EMAIL PROTECTED] Author of "Practical Ajax Projects With Java Technology" (2006, Apress, ISBN 1-59059-695-1) Java Web Parts - http://javawebparts.sourceforge.net Supplying the wheel, so you don't have to reinvent it! On Tue, November 28, 2006 3:43 pm, Adam Gordon wrote: > I have a JSP and there's a link in the rendered page that makes an AJAX > call > (to a Struts action) when clicked. The results of that action, and the > contents of the response are set as the innerHTML on a hidden <div> > defined > inside the afore mentioned rendered page. The <div> is then un-hid. > > Everything is working correctly except for one part: When the div is > displayed, the JavaScript code in the contents returned by the AJAX call > isn't being executed and thus, the contents of the <div> aren't set up > correctly. > > Does anyone know a way to have the JavaScript be executed? Or force the > browser to execute it? > > I used to have an <iframe> and everything worked great, but there was a > bad > side effect with session timeouts and so we've decided to not use them. > > Any help would be appreciated. Thanks. > > -Adam > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]