0

I have an encoding problem (only in Firefox, I tested with IE and Chrome) when I send a request with AJAX and AJAX requests only.

I'm under PHP5 / apache.

The encoding used in my site is ISO (for historical reasons), I can not change it (customer constraint).

So when I send data via an ajax request, they are retrieved UTF-8 despite that sending is done well in ISO (I checked via the debug console).

Headers of the request and page (PHP and HTML) are ISO-8859-1, as well as encoding of the page is in ISO.

I checked the php.ini settings and those of the httpd.conf, it is makes no mention encoding in UTF-8. When that was the case I changed the lines to iso.

I also tested the additions as follows "AddDefaultCharset iso-8859-1" at the http.conf or .htaccess, but nothing there.

Note that this problem has occurred since august 26, why ? (no deployment)

If anyone had the same problem and has a solution or a track start, I thank in advance.

I already try something like that :

$.ajax({
    url: 'page.php?controller=test_encodage&civ='+civ+'&nom='+nom+'&prenom='+prenom+'&qualite='+qualite+'&afficher=1',
  type:'POST',
  contentType: 'application/x-www-form-urlencoded; charset=iso-8859-1',
     beforeSend: function(jqXHR) {
         jqXHR.overrideMimeType('text/html;charset=iso-8859-1');
     }
    });

and it's steel doesn't work

  • If you send an AJAX request from the site in the internet browser, make sure to set **contentType** to `application/x-www-form-urlencoded;charset=ISO-8859-1` instead of leaving it undefined. I can't help any further since you didn't provide one single line of code. – AmigoJack Oct 10 '16 at 15:21
  • I already try something with the content type, i add some lines of code to my post. thanks for your help. – IdoineConseil Oct 11 '16 at 07:15
  • Oh, we're talking about **jQuery**, which you never stated. If you got that from http://stackoverflow.com/a/14397845/4299358 or http://stackoverflow.com/a/16340345/4299358 and it did not help (I'd not volutarily use lowercase letters or a missing space) then go to the PHP side and check the request data. How about isolating the problem and writing a test case with one PHP file only? And are we having problems with the request to the server being in the wrong encoding or with the response you get? Or even both? – AmigoJack Oct 15 '16 at 16:17
  • Thanks for your help. In PHP side i just "var_dump" posted data and every time they are encode into UTF-8. So i think my problem is from javascript side, but even if i add options for ISO encoding, it's steel encoding into UTF-8 (Only with Firefox). My request is weel encode into ISO (i can checking that with debug console of firefox) – IdoineConseil Oct 17 '16 at 13:25

0 Answers0