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:
- <script type="text/javascript" src="jquery-1.3.2.js"></script>
- <script type="text/javascript" src="jquery-ui-1.7.2.custom.js"></script>
- <script type="text/javascript">
- jQuery.createXMLDocument = function( s ) {
- var browserName = navigator.appName;
- var xmlDoc;
- if ( browserName == "Microsoft Internet Explorer" ) {
- xmlDoc = new ActiveXObject( "Microsoft.XMLDOM" );
- xmlDoc.async = "false";
- xmlDoc.loadXML( s );
- } else {
- xmlDoc = ( new DOMParser() ).parseFromString( s, "text/xml" );
- }
- return xmlDoc;
- }
- function test() {
- var xmlDoc = jQuery.createXMLDocument( "<items></items>" );
- jQuery( "items", xmlDoc ).append( jQuery( "<item>Hello World!</item>" ) );
- jQuery.ajax({
- url: "http://localfile/getXML.php",
- type: "POST",
- processData: false,
- contentType: "text/xml",
- data: xmlDoc,
- success: function( data ) {
- alert( data );
- }
- });
- }
- </script>
my getXML.php looks like this:
- <?php
- $xml = file_get_contents( "php://input" );
- $simpleXml = simplexml_load_string( $xml );
- $simpleXml->xpath( "/items/ITEM" );
- foreach ( $simpleXml as $item ) {
- echo $item."\n";
- }
- ?>
Everything works fine in Firefox (3.5.7) on LInux.
Problem is on IE 6.0.2900 in Windows.
I get an error:
Line: 12Error: Type MismatchAnd 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