Login Register

dojo.io.*

<head>
        <script type="text/javascript" src=dojoroot/dojo/dojo.js djConfig="parseOnLoad: true"></script>
        <script type="text/javascript">
      dojo.require("dojo.event.*");
      dojo.require("dojo.widget.*");
      dojo.require("dojo.widget.Button");
dojo.require("dojo.string.*");
        dojo.require("dojo.io.iframe");
        dojo.require("dojo.io.script");
      dojo.require("dojo.io.ScriptSrcIO");

      function helloPressed()
      {
              alert('Click on the Hello World Button');
            dojo.io.bind({url: "http://www.google.com/",
                                                        transport: "ScriptSrcTransport",
                                                        load: function(type, data, event) { /* type will be "load", data and event null */ alert('Load'); },
                                                        error: function(type, data, event) { /* type will be "error", data and event will have the error */ alert('Error'); },
                                                        timeout: function() { /* Called if there is a timeout */ alert('Timeout');},
                                                        timeoutSeconds: 10 //The number of seconds to wait until firing timeout callback in case of timeout.
                        }
                     );
      }

      function init()
      {
      var helloButton = dojo.widget.byId('helloButton');
      dojo.event.connect(helloButton, 'onClick', 'helloPressed')
      }

    dojo.addOnLoad(init);
    </script>
         </head>
         <body>
                <button dojoType="Button" widgetId="helloButton" onClick="helloPressed();">Hello World!</button>
<br>
         </body>

?

A snippet of code (particularly a combination of Dojo 0.4 and 0.9+) tells us nothing about what your question is or why you posted it.

Do you have a question about this, or a comment? Perhaps you are looking for this? http://dojotoolkit.org/book/dojo-porting-guide-0-4-x-0-9 ?

I am unable to use dojo.io.bind

Can you please tell me how to use dojo.io.bind?.
Actually I want to make a request to a external url.

Dojo 1.0.2

I am new to Dojo so dont have much idea about it. Can some one please guide me how to use dojo.io.bind in Dojo 1.0.2. I want to make a request to external URL.
How can I use dojo.io.bind for that, or is there any other way to do that?.
If you can explain with an working example that will be great help.

Thanks in advance
Harmeet

Still not working

Below is the code which I am trying to execute, but no luck. If I am doing something wrong please correct me.

<head>
  <title>Hello, Ajax world!</title>
  <script type="text/javascript"
    src="http://o.aolcdn.com/dojo/1.0.0/dojo/dojo.xd.js">
</script>
  <script type="text/javascript">
       function hello() { //
        alert('Test');
     dojo.xhrGet({url: "http://www.google.com",load:function(response, ioArgs){alert(data);
        },
        error: function(response, ioArgs){
                alert('Holy Bomb Box, Batman!  An error occurred');
        },
        timeout: 2000
});

      }
  </script>
  <script type="text/javascript">
    dojo.addOnLoad(hello); //
  </script>
 </head>
 <body>
   <div id="cargo" style="font-size: big"></div>
 </body>

You cannot do cross-domain requests using XHR.

This is a deliberate security policy put in place by browser manufacturers; the only things you can load via xhr are things on the same domain where the code originates.

You can try using the io.iframe transport but that comes with it's own set of issues (again, both should be in those links I posted to you).

Help needed

I am still unable to implement the above functionaly. I have also tried to put a servlet in between DOJO & External URL but when the servelt respond's I get a message "Holy Bomb Box, Batman! An error occurred" in below mentioned error section. Can some one please guide me, with some running sample code for Dojo 1.0.2 .

function hello() { //
alert('Test');
dojo.xhrGet(
{
url: "<%=request.getContextPath()%>/TestServlet",
load:function(response, ioArgs){alert(data);
},
error: function(response, ioArgs){
alert('Holy Bomb Box, Batman! An error occurred');
},
timeout: 2000
});

Your code looks fine -

Your code looks fine - assuming that the server resource specified in "url" is valid.

The problem you're having appears to be caused by the URL referencing a resource that is not valid on the server. To debug this you need to see exactly what URL is being called. A good way to do this is to use Firebug (a FireFox plugin) to see what the full URL is.