0

I'm using a jsonp call (jQuery.getJSON), data returned is an XML. I can read it nicely in FF & IE9, but it is not working on IE8.

I can not use the dataType solution suggested in this SO question since I'm using a jsonp call. In the callback I parse the XML

$(xml).find("title").text()

Works fine with FF and IE9, fails with IE8. What can I do ? PS: using jQuery1.4

Community
  • 1
  • 1
millebii
  • 1,277
  • 2
  • 17
  • 27

2 Answers2

0

I believe the problem is that IE8 has the title tag reserved for the HTML document. Attempts to use it in XML data fails. I suggest an easy hack that I just used on a project where the title tag name was replaced with 'titlex' This will defeat ie8 and allow you to retrieve title elements in a XML file such as a RSS feed.

xml = xml.replace(/title/g, 'titlex'); //hack for ie8
var title = $(this).find('titlex').text(); //success!
mbokil
  • 3,202
  • 30
  • 22
0

You are using getJSON, which "Load JSON-encoded data from the server using a GET HTTP request.", and return XML-encoded data ?
I think there is your problem.

Try to use jQuery.get instead with dataType 'xml', but it should work without:
jQuery.get( url, [ data ], [ success(data, textStatus, jqXHR) ], [ dataType ] )

jQuery.getJSON
jQuery.get

GMO
  • 669
  • 1
  • 6
  • 11
  • yes indeed I'm using getJSON. the server returns a json encoded data thus dataType=json, however the content of that data is an XML which I need to query. I will try you idea and report back. – millebii Mar 09 '11 at 11:05
  • did try your option using $.ajax call... did not work better. – millebii Mar 09 '11 at 12:15
  • If i understand well, your xml contains a ? Maybe IE8 don't support this tag. – GMO Mar 09 '11 at 14:30
  • I had a problem yesterday with jQuery('') on IE8. I switched it to jQuery('', {'class':'title'}). – GMO Mar 09 '11 at 14:31