Send XML to the server gets "Type Mismatch" error in IE, though works fine with Firefox

Send XML to the server gets "Type Mismatch" error in IE, though works fine with Firefox

Hi

I have followed instructions on this page:
http://blog.reindel.com/2009/06/10/sending-an-xml-document-object-to-php-with-jquery/

and in my case I added following to the HEAD section:

  1. <script type="text/javascript" src="jquery-1.3.2.js"></script>
  2. <script type="text/javascript" src="jquery-ui-1.7.2.custom.js"></script>
  3. <script type="text/javascript">
  4. jQuery.createXMLDocument = function( s ) {
  5.     var browserName = navigator.appName;
  6.     var xmlDoc;
  7.     if ( browserName == "Microsoft Internet Explorer" ) {
  8.         xmlDoc = new ActiveXObject( "Microsoft.XMLDOM" );
  9.         xmlDoc.async = "false";
  10.         xmlDoc.loadXML( s );
  11.     } else {
  12.         xmlDoc = ( new DOMParser() ).parseFromString( s, "text/xml" );
  13.     }
  14.     return xmlDoc;
  15. }
  16. function test() {
  17.     var xmlDoc = jQuery.createXMLDocument( "<items></items>" );
  18.     jQuery( "items", xmlDoc ).append( jQuery( "<item>Hello World!</item>" ) );
  19.     jQuery.ajax({
  20.         url: "http://localfile/getXML.php",
  21.         type: "POST",
  22.         processData: false,
  23.         contentType: "text/xml",
  24.         data: xmlDoc,
  25.         success: function( data ) {
  26.             alert( data );
  27.         }
  28.     });
  29. }
  30. </script>


my getXML.php looks like this:
  1. <?php
  2. $xml = file_get_contents( "php://input" );
  3. $simpleXml = simplexml_load_string( $xml );
  4. $simpleXml->xpath( "/items/ITEM" );
  5. foreach ( $simpleXml as $item ) {
  6.     echo $item."\n";
  7. }
  8. ?>

Everything works fine in Firefox (3.5.7) on LInux.
Problem is on IE 6.0.2900 in Windows.
I get an error:
Line: 12
Error: Type Mismatch

And when I start debugger it points me to
I.appendChild(G[J])
from file jquery-1.3.2.js

looks like a bug.

Or maybe I did something wrong ????

any ideas ?

regards
Rafal