I am trying to post data to a database and the campaigns run in 6 languages, 1 being Russian and its unable to handle the Cyrillic text.
The DTB is setup for UTF8 as the last campaign also used Russian, but jQUery with that one.
$(document).ready(function ()
{
$("#form").submit(function ()
{ //Use forms ID
var str = $(this).serialize();
$.ajax({
type: "POST",
url: "includes/postData.php",
data: str,
success: function (msg)
{
if (msg == 'OK')
{
//alert('success');
$('#thankYou').delay(100).fadeIn(350);
} else
{
result = msg;
console.log(msg);
}
}
});
return false;
});
});
The error I am getting is "Incorrect string value: '\xC3\x91\xC2\x80\xC3\x91...'"
Tried editing the post data with
$country = utf8_decode($_POST['country']);
Which posts, but then its all ?'s in the DTB.
How would I get jQuery to correctly handle this post fur Russian. Any help will be much appreciated.
After some trial, error, another forum and plenty of google I found a solution. Wrap a decodeURI around the str variable.
var str1 = $(this).serialize();
var str = decodeURI(str1);
That fixes up the URI string that jQuery parses on to the post data