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/']
Just for information and to help others that might fall in the same situation...

The problem was with the postData itself... it was parsed such that every post variable was applied with escape()... Using encodeURIComponent() instead of escape() worked!

**Summary:**
Donot use escape() function to url-escape query components... use encodeURIComponent() instead...
Try changing the column in the database to utf16\_bin Collation

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