In general, the problem is that when I have data from the database loaded by the AJAX, they are outputted by short messages, if I request a file directly, then I get the answer in a normal form, and when I do that, then I have the pff .. Here is the code of all the files that are used. When connecting to the database, I specify the encoding in which the data should come.

$charset = "cp1251"; mysql_set_charset($charset, $dblink); 

I also specify the encoding in the script

 $.ajax({ url: file+".php", cache: false, scriptCharset: "cp1251", success: function(data){ $(".body").html(data); 

All data in the database is also recorded in cp1251 encoding, all scripts and phpshniki are also in cp1251 encoding. What to do, now I almost will not hang.

1 answer 1

In the Ajax request it is worth sending the generated header:

either this one:

 header('Content-type: text/plain; charset=cp1251'); 

either this one:

 header('Content-type: text/html; charset=cp1251'); 

Try to specify this title explicitly via php. It will help. You need to play with it.

  • Thanks, helped))))) - Michae Nikolaev
  • On health) - Gena Ant