I am using this ajax code to send data to server:

```
$.ajax({
    data: postData,
    type: method,
    url: url,
    timeout: 20000,
    contentType: "application/x-www-form-urlencoded;charset=UTF-8",
    error: function(jqXHR,textStatus,err){alert("Error returned from ajax call "+err);},
    success: function(data,status,jqXHR){
        // process response...
    }
});

```

`postData` is a query string with many values while `method` is `GET` or `POST`

The problem is that, when I send a query string that contains a value like `Älypuhelimen lisävarusteet`, the result in database is `�lypuhelimen lis�varusteet`

The database connection collation is utf-8, and this works fine when I do not use ajax to post and save to database... It is definitely ajax that messes up the encoding...

I have also tried using encodeURIComponent() function on the data, and it becomes `%C4lypuhelimen%20lis%E4varusteet` if I use it... same goes for escape() function...

any help will be appreciated...
['https://Stackoverflow.com/questions/37849294', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4575293/']
You should try jQuery Base64 encode.

JavaScript:

```
<script src="jquery.min.js"></script>
<script src="jquery.base64.min.js"></script>
<script>
    enctext = $.base64.encode("yourtext");
    //your ajax code goes here.
</script>

```

PHP : 

```
<?php
   $org_text = base64_decode($_POST['your_variable']);
?>

```

jQuery Base64 plugin.

download from here.

<https://github.com/carlo/jquery-base64>
Try changing the column in the database to utf16\_bin Collation

> 
> Post you php database connection code.
> 
> 
>