0

I found an issue trying to update a Postgres database (UTF-8) from an ajax call which contains Turkish characters in their body. I have a simple json with id and name attributes, name contains 'Kumar oyunları risk taşır' and on the database is saved "Kumar oyunlar�� risk ta����r"

        $(document).ready(function () {
            $("#sendToServer").click(function(){
            var json = '{"name":"Kumar oyunları risk taşır", "id": 123'}; 
            var server = "http://10.16.0.89:8080";
            var apiURL = server + "/api/content/publish/create";
            var dataform = new FormData();
            dataform.append('json', JSON.stringify(json));

            getURL = $.ajax({
                url: apiURL,
                type: 'PUT',
                cache: false,
                data: dataform,
                contentType:false,               
                success: function (result, request, response, data, status, xhr) {
                    alert('Success!');
                }
            });
        });
...
<button id="sendToServer">Send to server</button> 

There is no issue if json is used instead of dataform ( data: json ) BUT I really need it to use it because I gotta append a file in my app.

MJ-79
  • 133
  • 3
  • 10
  • Without the server side code we can only guess – Musa Feb 23 '18 at 12:35
  • One detail I forgot to say that it was working fine in my local environment, ok, finally as I thought the problem was Tomcat encoding, I've just followed solution on https://stackoverflow.com/questions/11089783/character-encoding-issue-with-tomcat and that's it – MJ-79 Feb 26 '18 at 15:17

1 Answers1

0

Problem was on Tomcat side, I just follow this solution: Character encoding issue with Tomcat and it's working perfect now.

MJ-79
  • 133
  • 3
  • 10