CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Mar 2008
    Posts
    3

    AJAX and special characters

    hi everyone.

    Am trying to get some data (in french) from a database, but the special characters like "é" are getting replaced by question marks. I have been able to find a way in mozilla using

    xmlHttp.overrideMimeType('text/xml; charset=iso-8859-1');

    but it is not working in IE7 and IE6.

    here are the codes :

    Code:
    function showArticles(rubrique)
    		{ 
    			xmlHttp=GetXmlHttpObject();
    			if (xmlHttp==null)
    			  {
    			  alert ("Your browser does not support AJAX!");
    			  return;
    			  } 
    			var url="displayTable.php";
    			url=url+"?r_id="+rubrique;
    			xmlHttp.onreadystatechange=stateChanged;
    			xmlHttp.open("GET",url,true);
    			xmlHttp.send(null);
    		}
    
    
    
    function stateChanged() 
    		{ 
    			
    			if (xmlHttp.readyState==4)
    			{ 
    				document.getElementById("dynamicTable").innerHTML=xmlHttp.responseText;
    			}
    		
    		}
    
    
    
    
    function GetXmlHttpObject()
    		{
    		var xmlHttp=null;
    		try
    		  {
    		  // Firefox, Opera 8.0+, Safari
    		  xmlHttp=new XMLHttpRequest();
    		  xmlHttp.overrideMimeType('text/xml; charset=iso-8859-1'); //NO CHARACTER PROBLEM IN MOZILLA
    		  }
    		catch (e)
    		  {
    		  // Internet Explorer
    		  try
    		    {
    		    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    			//xmlHttp.overrideMimeType('text/xml; charset=iso-8859-1'); // THIS DOES NOT WORK, I"VE COMMENTED IT
    		    }
    		  catch (e)
    		    {
    		    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    		    }
    		  }
    		return xmlHttp;
    		}
    Last edited by PeejAvery; March 22nd, 2008 at 04:12 PM. Reason: Added code tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured