jQuery Version Shuffle

Today I tried to run…

Login

Blog History

Today I tried to run the following javascript using jQuery 1.4.2 on IE8 under Windows XP Pro SP3:

// returns 'pallet' tabname
var tab = get_tab(); 
// returns 'pallet-item' text input field
var target_field = get_target_field(tab); 
// works in firefox and chrome but not IE. grrrr
var item = $('#' + target_field ).val(); 

I recieved this error in IE 8:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Timestamp: Mon, 26 Mar 2012 23:38:38 UTC

Message: Object doesn't support this action

The reason I was running the older jQuery version was because of a jQuery XML namespaced node parsing problem https://toggen.com.au/it-tips/jquery-nodenamens1result-syntax-no-longer-works

So I was stuck with the older version of jQuery. But that was until I found this post on XML namespace parsing http://www.steveworkman.com/html5-2/javascript/2011/improving-javascript-xml-node-finding-performance-by-2000/

So by upgrading to jquery-1.7.2.min.js I found the code above worked on IE8.

Then by changing my XML code to include the .filterNode code from the above site I was able to get my SOAP XML parsing properly with the latest version of 1.7.2 removing the dependence on the old jquery.

// put this in a separate file and include it in your html document head
// e.g.
// 
// using this jquery custom function from Steve Workmans post
$.fn.filterNode = function(name) {
      return this.find('*').filter(function() {
        return this.nodeName === name;
      });
    };

// this old code 
var response = $(qdoc_response).find('[nodeName=ns1:result]').text();

// becomes this 
var response = $(qdoc_response).filterNode('ns1:result').text();

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.