views:

111

answers:

3

Hello, i'm using jquery 1.4.2 to send an ajax request to a php page then display the result.

This works fine with FF3 and IE8, but in IE6 the character € is replaced by a square, i tried to force the character encoding of the php page using header() but it didn t work...

I'm working on windows with Zend Studio for eclipse (projet encoding is utf-8)

here is the ajax call :

$.ajax({
  url:'index.php?module=ajax&action=getCommande&no-header=1&id='+id ,
  cache:true,
  success:function(html){
    $("#recap_commande").html(html);
  }
});

requested page :

<?php
header('Content-type: text/html; charset=utf-8');
echo "Récapitulatif de la demande " . $_GET ['id'] . " (".$this->getTotal($nb["COD_ART"],$nb["COD_OPTION"])." €) ";
?>

Any help will be appreciate.

A: 

I would recommend you to avoid concatenating parameters as you did. Use the data hash like this so that jQuery take care of properly encoding url values:

$.ajax({
    url: 'index.php',
    cache: true,
    data: { module: 'ajax', action: 'getCommande', no-header: '1', id: id },
    success: function(html) {
        $('#recap_commande').html(html);
    }
});

Also make sure that your pages are utf-8 encoded.

Darin Dimitrov
thanks for this tip! i will use data now.I verified encoding (using notepad++) it's utf-8 without BOM.Here is a sample of the firebug headers of the response , encoding seems correct. Réponse Date Tue, 24 Aug 2010 13:37:34 GMT Server Apache/2.2.15 (Win32) DAV/2 SVN/1.6.6 X-Powered-By PHP/5.3.2 ZendServer Transfer-Encoding chunked Content-Type text/html; charset=utf-8
Kayasax
A: 

On some computers, the Euro character might not be in the font being used by IE6. Another possibility is that IE6 is merely incapable of correctly rendering the character. This is a known problem with older Microsoft products, but I don't know if it extends to IE6 or not. I do know that, if the font is missing, IE will display the numerical character code (&#8364;) as a small box rather than €.

Your safest bet is to use some kind of filtering to degrade gracefully for older browsers. I'd recommend adding this just before your AJAX call:

var IEsix = ($.browers.msie && $.browser.version.substr(0,1)<7) ? true : false; 

Then pass this new variable along with your AJAX request and have your server-side script change its formatting based on whether or not you're serving data for IE6. For most browsers, you could say something like "€44". For IE6 you could instead return "44 Euros."

EAMann
Hello and thank you for respondingwell, ie6 display correcty € when i'm not using ajax...It's an intranet application and 'official' browser is IE6 so i cannot simply not use this character...
Kayasax
In that case, what is the actual character code being returned by AJAX? Is it ⁈ or €?
EAMann
I tried : € , € and € none of them worked
Kayasax
I understand that none of them work ... but what is the actual character code that's creating the square when your AJAX returns data? Knowing what AJAX is returning will help us figure out what's going wrong in the transfer.
EAMann
i guess it's € (this is what is shown in an alert box )
Kayasax
A: 

Sorry, this was a specific computer problem, the euro sign is correctly display on another computer with same OS and IE6 ....

I dont understand where the problem came from , i tried to empty the cache still the same... when alerting ajax response the € is correctly display, when copy the square character then paste it in notepad i can see the € ! ??

my life will be so much simplier without this stupid ie6!

Kayasax