Internet Explore, Firefox, AJAX & “Could not complete the operation due to error c00ce514” message


I’ve been working on some code which use Ajax for autocomplete implementing. to accomplish this mission I’ve created :

  1. Database (unicode_general_ci)
  2. HTML page which show the results of the autocomplete, encoded as UTF-8 with ‘Content-type: text/html; charset=utf-8’
  3. PHP file which used to query the Database, also encoded as UTF-8 with ‘Content-type: text/html; charset=utf-8’ and “SET NAMES ‘UTF8′” query to the database.

so.. as it sounds.. all the parts configured well for using UTF-8. so let’s see… in Firefox.. the code is working great, in Internet Explorer, I’m getting the error : “Could not complete the operation due to error c00ce514”, this error indicates that Microsoft XML Parser is having problems when parsing the AJAX response string.

the reasons for this error are :

  1. the encoding of the requested file
  2. or the encoding of the sent string…

the first reason could be solved by setting the charset with the header command… the second (which solved my problem..) is to encode the sent string. in my case I sent the string by GET method :

<input name=”autotxt” type=”text” onkeyup=”loadXMLDoc(‘findtxt.php?str=’+this.value)”>

the string that was sent to the “findtxt.php?str=” wasn’t encoded in UTF-8 somehow so… I made a little change of the code like this :

<input name=”autotxt” type=”text” onkeyup=”loadXMLDoc(‘findtxt.php?str=’+encodeURIComponent(this.value))”>

The encodeURIComponent() function encodes a URI component. This function encodes special characters. In addition, it encodes the following characters: , / ? : @ & = + $ #

That’s it, have fun.

Leave a Reply

Your email address will not be published. Required fields are marked *