Solved

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

Posted on 2006-11-22
4
410 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

813 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

12 Experts available now in Live!

Get 1:1 Help Now