• Home
  • New Entries
  • Popular Entries
  • Submit a Story
  • About

How Hard is AJAX Coding ...

I spent some time playing with Bob Buffone's newest work on Ajax over the last few days. Bob built an xModify processor that runs on either jQuery, Dojo or Mootools. The xModify processor is powerful but quite lightweight (10KB without gzip).

There will be more news on xModify  but that is not the point of this post.  Anyway, I wrote a little app that uses his stuff. The entire application uses three JavaScript file: jQuery library (70KB), xModify processor (10KB) and my little JavaScript file (2KB).

My target is to run the little app on Internet Explorer and FireFox. In particular, I have used FireBug on FireFox during development. FireBug is a popular FireFox browser add-on that provides JavaScript debugging capability. After a little while, without a lot of effort (thanks to FireBug, jQuery and xModify), my app is working. It does exactly what I  intended. Flawlessly.

Then I  applied a modified version of ShinkSafe, reducing the number of round trips as well as download size. ShrinkSafe is a tool provided by Dojo that compresses JavaScript files. Using ShrinkSafe,  the three JavaScript files are combined into one and the total download footprint also reduced by about 30% to 40%. The result worked well on  both IE and FireFox. At this point, I happily concluded my little project and moved onto my day job of web browsing.

However, it turns out that my browsing experience is unusually slow at this moment. Eventually I realized it is because I have my FireBug turned on due to my earlier little project. After I disabled FireBug, web browsing resumed its normal performance.

A few hours later when I tried to run my little application again, it surprisingly failed on FireFox. The app loads into FireFox, but it does not respond to any user interaction. It is not frozon or dead, as I can still type into text fields. It looks fine too as the UI is still rendered correctly.  But it is just not responding to any event such as "submit" or "click". On IE, the application is still working fine.  The only thing that is changed is that I have FireBug disabled now. Would disabling FireBug break my app? Hard to imagine. Nevertheless, I re-enabled FireBug. Surprisingly the application is working again. If I disable FireBug, the application stops working. So does disabling FireBug actually break my application?

There is one error message on the JavaScript console:  Error: uncaught exception: [Exception... "Not enough arguments"  nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)"  location: "JS frame :: http://localhost:1000/app/javascript/jquery/all.js :: anonymous :: line 1"  data: no]

What does the error message mean? Where does the error come from?

My natural intuition is that my modified ShrinkSafe is the trouble maker here. It may have screwed up one or two characters when compressing jQuery, xModify or my own JavaScript code. For example, it may have incorrectly removed a ";" from the JavaScript source. IE browser and FireFox with FireBug turned on are able to handle this issue but FireFox without FireBug is not able to interpret  JavaScript statements with a missing ";".

Well, now enters a four-hour exciting debugging session....

After four hours, I finally figured out the problem. It is not FireBug. It is not ShrinkSafe. It is actually a coding issue in my little JavaScript code. In my code, I used "XmlHttpRequest" object. Here is the code snippet:

           if (window.XMLHttpRequest)  req = new XMLHttpRequest();
           else if (window.ActiveXObject)        
                    req = new ActiveXObject((navigator.userAgent.toLowerCase().indexOf( amsie 5) != -1) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP");   
                       
            req.open("GET", url, false);       
            req.send();  

The problem is the "req.send()" statement. When you call "send()" method for an XHR object, FireFox  expects an argument for this method, even if it is "null". Without an argument, FireFox throws the above exception. Once I changed "req.send();" to "req.send(null);", the problem went away.

The strange thing is that that code works fine on IE, further, works fine on FireFox if FireBug is enabled. In a typical development environment where FireBug is enabled, the problem is never exposed. And then, in a production environment where FireBug is disabled, you get an error. But the message says "Error: uncaught exception: [Exception... "Not enough arguments"  nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)"  location: "JS frame :: http://localhost:1000/app/javascript/jquery/all.js :: anonymous :: line 1"  data: no]".
source: java.sys-con

 View Full Story.
Posted at 10:55:19 am | Permalink | Posted in Java  

Related Stuff

  • MooV: Using cutting edge Video phones and Software Video Phones - coupling all that with VoIP and empowering the disabled.

  • Moo Telecom: VoIP communications made easy - Ring anyway with the fun and ease of using a normal phone

  • TagR:Mobile Social Network with Real Time Locations Based services, and Ambience Intelligence, VoiP, IM, Skype, Googletalk, Mapping, Flickr, Events, Calendaring, Scheduling, SecondLife Support

  • ClearSMS : ClearSMS is a Web-based application that lets you send bulk SMS messages to your customers, contacts, or just about anyone.

  • Jajah:jah is a VoIP (Voice over IP) provider, founded by Austrians Roman Scharf and Daniel Mattes in 2005[1]. The Jajah headquarters are located in Mountain View, CA, USA, and Luxembourg. Jajah maintains a development centre in Israel.

  • Skype: It’s free to download and free to call other people on Skype. Skype the number one voice over ip software

  • PrivatePhone: a free local phone number with voicemail and messages you can check online or from any phone.

2 Comments |Add your comment.

alain said:

Spent hours to find that answer...

Posted at August 23, 2008 11:21:11 pm
Dimitar Christoff said:

Great find and it certainly helped me along in finding the cause of this oddity... You never think of trying to test a site without firebug... heh!

Posted at November 30, 2007 02:18:11 pm

Your Comment ...

  Name (required)

  Email (required, hidden)

  Website


Top Stuff

e-messenger

MessengerFX

eBuddy

ILoveIM

AIM Express

Top 20 Ruby CMS


Our Partners

Facebook Applications

Ajax Projects

Web 2.0 Sites

Webloglines

Human Development Handbook

Software Development Company

Ajaxlines

Stock Exchange Chat


About Ajaxlines

Ajaxlines is a project focused on providing its audience with a database of most of Ajax related articles, resources, tutorials and services from around the world.

Its purpose is to showcase the power of Ajax and to act as a portal to the Ajax development community.


Search


Topics

  • .Net (111)
  • Articles (85)
  • Bookmarking (35)
  • Calendar (19)
  • Chat (39)
  • ColdFusion (3)
  • CSS (41)
  • Email (23)
  • Facebook (23)
  • Flash (15)
  • Games (6)
  • Google (28)
  • Html (14)
  • Image (11)
  • International Calls & VOIP (7)
  • Java (36)
  • Javascript (171)
  • JSON (21)
  • Perl (2)
  • PHP (88)
  • Presentation (19)
  • Python (3)
  • Resources (2)
  • RSS (1)
  • Ruby (10)
  • Storage (4)
  • Toolkits (90)
  • Tutorials (199)
  • UI (12)
  • Utilities (167)
  • Web2.0 (13)
  • XmlHttpRequest (20)
  • YUI (4)

© 2006 www.ajaxlines.com. All Rights Reserved. Powered by IRange