jQuery AJAX module vs Opera
March 9th, 2006
- Category:
- JavaScript,
- Web Development,
- jQuery
The AJAX module for jQuery currently does not work with the Opera browser. I already posted this to the jQuery mailing list and I expect this soon to be fixed, but if you cannot wait for that, download the latest uncompressed source, locate the following lines (lines 5 and 6 actually):
if ( typeof XMLHttpRequest == 'undefined' ) {
function XMLHttpRequest() {...
and change them to this:
if ( typeof XMLHttpRequest == 'undefined' && typeof window.ActiveXObject == 'function' ) {
window.XMLHttpRequest = function() {...
Although function XMLHttpRequest() { ... should be the same as window.XMLHttpRequest = function() {... (every global function is a property of the window object) Opera does not get that right.
I also recommend checking for the existence of ActiveXObject before using it, in order to let the script degrade gracefully in browsers supporting neither XMLHttpRequest nor ActiveXObject. With the as-is code any browser without support for XMLHttpRequest will instantiate an ActiveXObject object, which of course will result in an error if there isn’t such object.
You can then compress the code yourself with Dean Edwards JavaScript packer and intregrate it.
Have fun!
Comments are closed.