Subscribe to e_i_pi's Blog        RSS Feed
-----

The importance of updating jQuery

Icon Leave Comment
While I would recommend testing a new jQuery library on your site before implementing it, I also strongly recommend keeping your jQuery library up-to-date as much as you possibly can. This is why...

I have recently resolved a problem on my site, and it took me about 5 hours to discover what the problem was - that I was running v1.5.1, instead of the lastest version 1.7.1.

I was in the process of revising working code (from procedural to OO), and had reached the part of my code that allowed users to upload files via AJAX requests. For this I have always used Mike Alsup's jQuery Form Plugin. I have never had any problems with this plugin, and have successfully used it on a number of occassions. Once I had written the new code, I tested it out, thinking there may be the usual minor bug fixes, but that it should all run fine. I was wrong...

Whenever I tried to upload a file, no matter what the file format, the error console in Firebug would state "too many recursions". Ouch. Searching on Google didn't really help. The main way people had encountered this problem was by calling a .submit() method as a callback on a .validation() method - and since .submit() calls .validation(), it creates a circular reference. I knew that I was not doing this in my code, so I had to go back to the drawing board.

I tried multiple different vectors to get the code to work - and none of them came up roses. In my frustration, I decided to foment the code down to it's essentials, and post a cropped non-working version of the code here for people to assist me. One small problem - the cropped code worked fine. I could not replicate the error!

Next I decided to try a few other points of attack. Firstly I tried running my site in IE, rather than Firefox, and I finally got some progress. The code worked fine in IE. I thought maybe this could be a problem with Mike's library, and was tossing up whether to email him, but I thought I'd try a few other things first, and this is where I discovered the problem.

I went back to the cropped code, and dropped in all my script references that are in my website, et voila, the code stopped working in Firefox. I realised that it was likely a library conflict, but could be an upgrade issue. After subbing in the Google API for my local jQuery file, the problem resolved. I needed to upgrade my jQuery.

Let this be a warning to fellow coders - always keep your jQuery library up to date. Browser manufacturers change their software regularly, and the jQuery crew are pretty good at keeping on top of these changes. The root cause of my problem was that jQuery 1.5.1 was not compatible with Firefox 8.0, or in other words, that I was running outmoded jQuery code.

0 Comments On This Entry

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

April 2014

S M T W T F S
  12345
6789101112
13141516 17 1819
20212223242526
27282930   

Tags

    Recent Entries

    Search My Blog

    0 user(s) viewing

    0 Guests
    0 member(s)
    0 anonymous member(s)