[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 429
  • Last Modified:

Dojo 0.4 io.bind() not working on Firefox 2.0

Hi,

I'm hoping this is a silly issue, but I'm still assigning max points because it's urgent.

Can someone tell me why I'm getting the following (seemingly non-?)error when I call dojo.io.bind() with Dojo 0.4 in Firefox 2.0 on Win XP SP2?  The same code works fine on IE 6.  The dojo.io.bind() is calling (a local) IIS; I did verify that the a.php module does get run in both the Firefox and the IE cases.

Error message:  "error: XMLHttpTransport Error: 0"

Here's the code:

a.html
--------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
      <script type="text/javascript">
            var djConfig = { isDebug: true };
      </script>
      <script type="text/javascript" src="js/dojo/dojo.js"></script>
      <script type="text/javascript">
            dojo.require("dojo.event.*");
            dojo.require("dojo.io.*");
      </script>

      <script type="text/javascript">
            function doBind(evt)
            {
                  var bindArgs = {
                        url: "a.php",
                        load: function(type, data, evt)
                        {
                              alert("success");
                        },
                        error: function(type, err)
                        {
                              alert("error: " + err.message);
                        },
                        mimetype: "text/plain"
                  };

                  dojo.io.bind(bindArgs);
            }
      </script>

      <script type="text/javascript">
            function initEventHandlers()
            {
                  dojo.event.connect(dojo.byId("btnTest"), "onclick", "doBind");
            }
      </script>

      <script type="text/javascript">
            dojo.addOnLoad(initEventHandlers);
      </script>
</head>
<body>
      <form id="frmLogin">
            <button id="btnTest">Test</button>
      </form>
</body>
</html>

a.php
-------
<?php

// Indicate content type.
header("Content-Type: text/plain; charset=utf-8");

print("TEST MESSAGE");

?>

-----------------------------------------
As you can see, this example is really simple, and as I mentioned it works fine on IE 6.  I don't see any JS errors in the Firefox JS error console.  I hope I'm just doing something dumb.  "Works for me" is also a valid answer; then I'd like to figure out what's different between your setup and mine.

If I can provide any more info let me know, and thanks...!
0
TruthHunter
Asked:
TruthHunter
  • 2
1 Solution
 
rama_krishna580Commented:
Hi,

Somewhere in dojo.io.bind stack looks like there's an edge case that isn't being handled (either by Dojo or Firefox - I'm not sure which).
http://www.ghidinelli.com/2006/07/25/dojoiobind-and-caching/
http://alex.dojotoolkit.org/?m=200512
http://www.dev411.com/blog/tag/json

R.K
0
 
TruthHunterAuthor Commented:
Wait - I did find the solution.  The problem was that the default JS event handler was still being fired in addition to doBind().  Adding a call to "preventDefault()" fixed it:

.
.
.
     <script type="text/javascript">
          function doBind(evt)
          {
               evt.preventDefault();

               var bindArgs = {
                    url: "a.php",
                    load: function(type, data, evt)
                    {
                         alert("success");
                    },
                    error: function(type, err)
                    {
                         alert("error: " + err.message);
                    },
                    mimetype: "text/plain"
               };

               dojo.io.bind(bindArgs);
          }
     </script>
.
.
.

Hope this helps someone else out there!  Points awarded to cem_turk since you bothered to reply... :^)
0
 
TruthHunterAuthor Commented:
Sorry - I meant rama_krishna580 ...!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now