Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lazy load not working with masonry js 1 22
Add shadow behind div 5 25
Javascript the "if condition with Or" 8 29
Page auto-refreshes when scrolled on iPhone. 5 55
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

860 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