How to get XML in IE8 using mootools

I am engaged in a network where I actively use AJAX requests for the XML service. In fact, my network is an interface with almost no server and uses AJAX to communicate with the back-end.

Everything went perfectly (I developed and tested in Ubuntu 9.04 and Firefox 3.0 as a browser). Once I decided to see how my network worked in IE8 ... horror!

Nothing worked, as it was fine in Firefox. To be more specific, Request.HTML did not work. As I said, my network relied heavily on this, so nothing worked.

I spent a day trying to start something, but I was not lucky .. The only conclusion I came to was that the XML was parsed incorrectly (I hope I'm wrong). Go to the code:

var req = new Request.HTML({ url: 'service/Catalog.groovy', onSuccess: function(responseTree, responseElements) { var catz = responseElements.filter('category'); catz.each(function(cat){ // cat = $(cat); var cat_id = cat.get('id'); var subcategory = cat.getElement('subcategory'); alert(cat_id); alert(cat.get('html')); alert(subcategory.get('html')); } }, onFailure: function(){...} }); 

for example, this piece of code. In firefox, it worked perfectly. He warned the ID (for example, 7), then he showed the contents of the category element, for example:

 <subcategory id='1'> <category_id>7</category_id> <code>ACTIO</code> <name>Action</name> </subcategory> 

and then he showed the contents of some internal element, in this case:

 <category_id>7</category_id> <code>ACTIO</code> <name>Action</name> 

In IE8, the first warning worked fine (warning 7) but the next warning (alert (cat.get ('html'));) gave an empty string and the last one threw an exception ... he said something about the beeing null subcategory.

What I concluded with this all is that the elements that parse correctly in Firefox, but in IE8 I received only the tags and attributes OK, everything else was completely wrong (in fact, missing). I mean, the inner content is all the elements of the answer that are gone!

Another fact you could use: this code:

 alert(cat.get('tag')); resulted in Firefox: category IE8: /category <-----------(?) 

hmm what else ... oh, yes ... the line you see above ( cat = $(cat); ) was something I tried to fix it. I read in Mootools Docs that IE needs to directly call the $ function on elements to get all Element-magic ... but that doesn't fix anything.

I was so desperate ... I even muttered mootools.js code

OK, so ... That I want you, dear mootool-pro, will help me solve this problem, because I really need a network to work in IE8, and in fact I chose mootools to forget about compatibility issues ...

ps: if something is not clear, please ASK! I would be grateful for any help: D

+1
source share
1 answer

I had a similar problem like this once with jQuery. The problem was that in IE, incoming response data must be processed by the Microsoft.XMLDOM ActiveX object.

General steps:

  • Activate an ActiveX Object.

    var oXmlDoc = new ActiveXObject("Microsoft.XMLDOM");

  • Transfer the incoming response data and download it.

    oXmlDoc.loadXML(sXmlResponseData);

  • Disassemble it as needed.

You can check the full resolution here .

+1
source

All Articles