0

Possible Duplicate:
jQuery .find() doesn't return data in IE but does in Firefox and Chrome

I get a xml with $.get then i do
$(theXml).find('content').html() works fine in firefox and chrome but it gives javascript error in IE
$(theXml).find('content').text() works fine

This is theXml i get <?xml version="1.0" encoding="UTF-8"?><response><status>1</status><result><content><div id="rr"><h1>fdasa</h1><img src="www.google.com"/></div></content></result></response>

And this error in IE
Error: 'this.0.innerHTML' is null or not an object.

edit:

This is happening in the callback of $.get request. The response is a XML where the <content> node contains the html markup. The response is first parsed using this function as intially it wasn't working in chrome and IE

    function parseXml(xml)
{   
        if (jQuery.browser.msie)
        {               
            var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.loadXML(xml);
            xml = xmlDoc;
        }
        return xml;
}


var theXml = parseXml(xml);

then we tried to get the html inside the content node using

$(theXml).find('content').html()
Community
  • 1
  • 1
jimy
  • 4,760
  • 3
  • 32
  • 49
  • 3
    Please **always** quote the exact error message you are getting. – Pekka Feb 28 '11 at 11:08
  • 2
    show us "theXml" by outputting it to screen – Jason Feb 28 '11 at 11:09
  • 1
    it maybe that it is a treated as a text area, or input, instead, so `.val()` could be another option... whats the `theXml` value? – Val Feb 28 '11 at 11:11
  • 2
    @jimy post the JavaScript error that you are receiving – dianovich Feb 28 '11 at 11:11
  • @Jason Error: 'this.0.innerHTML' is null or not an object – jimy Feb 28 '11 at 11:11
  • in firefox, assuming you have firebug installed, run this command: `console.log(theXml);` and paste the output into your question. – Jason Feb 28 '11 at 11:13
  • 1
    @Jason this is theXml i get `1

    fdasa

    '
    – jimy Feb 28 '11 at 11:14
  • @Pekka I didnt get you should i use .xml() instead of .html() ?? – jimy Feb 28 '11 at 11:16
  • There is no .xml(); Anyway I've tried it in Chrome and IE. Totally agreed- there's some issue here. The problem has something to do with IE ignoring non html markup. find('h1') works in IE, but find ('content') doesn't work – Jason Feb 28 '11 at 11:22
  • @Jason for me find('h1') is also not working – jimy Feb 28 '11 at 11:26
  • i think i know why this is, the content you are getting is an array of elements, therefor html(), doesn't know what to do, get all innerHTML for every `` tag or not, where it should only be getting a single element at a time, hence why your text() works, – Val Feb 28 '11 at 12:20

0 Answers0