struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andras Balogh <and...@reea.net>
Subject Re: executing inline scripts from ajax responses (dojo 0.4)
Date Mon, 30 Mar 2009 14:56:26 GMT
Hi,

    This is a little bit off-topic because it's related more to Dojo 
than Struts.
But anyway: do you get back something in your "data" object in function 
load()?
If you know that you are returning javascript do not send the <script> 
tag (only the javascript)
and use eval(data) instead of innerHTML.

BR,
Andras

Tedy Marcos Colombini wrote:
> Hi there,
>
> After being able to submit an ajax form request using javascript, I am stuck
> in the second (and last) problem. The response contains an inline script
> which I wanna execute when the it is rendered. I am using Struts 2.0.11 and
> Dojo 0.4. I did some research but everything I found is incomplete.
>
> This is the code. It works, only the alert from the response doesn't pop
> out. So what I should do to make this script run?
>
>
> <%@ page contentType="text/html; charset=UTF-8" %>
> <%@ taglib prefix="s" uri="/struts-tags" %>
> <html>
> <head>
>     <s:head theme="ajax" debug="true"/>
>     <script type="text/javascript">
>         function submitForm(formId, divId) {
>         var kw = {
>             formNode: dojo.byId(formId),
>             mimetype: "text/plain",
>             method: "post",
>             transport: "XMLHTTPTransport",
>             load: function(type, data, http, kwArgs){
>                 dojo.byId(divId).innerHTML = data;
>             },
>             error: function(type, error, http){
>                 alert(error);
>              }
>         };
>         dojo.io.bind(kw);
>     }
>     </script>
> </head>
>
> <body>
>     <s:form id="myForm" action="example/Test.action">
>         <input type="button" onclick="submitForm('myForm', 'divResult')"
> value="Javascript" />
>     </s:form>
>     <div id="divResult"></div>
> </body>
> </html>
>
>
> This is the response from Test.action:
>
> Content
> <script>
>     alert("test")
> </script>
>
>
> Thank you for your help,
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message