struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tedy Marcos Colombini <ted...@gmail.com>
Subject problems with struts and dojo
Date Fri, 27 Mar 2009 10:55:59 GMT
Hi guys, sorry for the previous email. I pressed some shortcut by accident.

I am trying to generate an ajax request with javascript. The code is very
simple but it doesn't work.
The message I get is: dojo.xhrGet is not a function (in Firefox error
console).

With a <s:form> and <s:submit>, I am able to generate a request.

So I am wondering if there is some configuration trick to be done when using
the javascript approach.

I am using Struts 2.0.11.

Thanks for your help.

Tedy.


This is the code that doesn't work:

<%@ 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() {
            var kw = {
                url: "example.HelloWorld!execute.action",
                handleAs:"text",
                load: function(response){
                    dojo.byId('divResult').innerHTML = response;
                },
                error: function(data){
                    console.debug("An error occurred: ", data);
                },
                timeout: 2000,
            };
            dojo.xhrGet(kw);
        }
</script>
</head>

<body>
    <input type="button" onclick="submitForm()" value="Javascript" />
    <s:div id="divResult"></s:div>
</body>
</html>

-- 
Tedy Marcos Colombini

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message