1

I wrote script that are sending data from HTML form to server using ajax request.

$.ajax({
    type: $(this).attr('method'),
    cache: false,
    url: $(this).attr('action'),
    data: $(this).serialize(),
    dataType: 'json'
});

I input data into my HTML form with: name = 'ładna pogoda'

My $_POST data in PHP script looks like: Array ( [name] => Ĺadna pogoda )

Data stored in MySQL: ?adna pogoda

It's possible to convert data to get utf-8 characters in my php script after serialize() data in javascript?

UPDATE:

My MySQL table was encoded with utf8-general-ci but somehow my columns where I stored data was latin1. When I changed it to table default it starts working.

L. Z.
  • 31
  • 5
  • 1
    Is your html/php file saved with utf-8 encoding? Is your database connection set to work with utf-8? Is your database table encoded as `utf8_general_ci`? – Perfect Square Jan 05 '18 at 19:24
  • https://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Sammitch Jan 05 '18 at 20:09
  • @StormoPL Thanks for advice, my table was encoded with `utf8_general_ci` but my columns was `latin1`. I changed it and now works fine :D Thanks – L. Z. Jan 05 '18 at 20:15

1 Answers1

0

Make sure that your HTML file is encoded in UTF-8 and that you declared proper charset in its head - in HTML5: <meta charset="UTF-8">. Making sure that your php files are also encoded in UTF-8 can be the next step if the first one does not resolve the issue.

Kwarcu
  • 141
  • 1
  • 4