Solved

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

Posted on 2006-11-22
4
407 Views
Last Modified: 2012-05-05
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
Comment
Question by:TruthHunter
  • 2
4 Comments
 
LVL 23

Accepted Solution

by:
rama_krishna580 earned 500 total points
ID: 17996621
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
 

Author Comment

by:TruthHunter
ID: 18159012
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
 

Author Comment

by:TruthHunter
ID: 18159022
Sorry - I meant rama_krishna580 ...!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now