I am sending an AJAX POST request using jQuery to the chrome extension, but the data does not arrive as expected, the shock characters are incorrect.
The text "HÄGERSTEN" becomes "HÃ" GERSTEN.
The text is displayed in the console, etc., only through AJAX to this other page, as described above. My AJAX call is basic, I am sending a data object via jQuery $ .ajax. I tried using without contentType, UTF-8 and ISO-8859-1. No difference.
Here's how I make my AJAX call:
var newValues = {name: 'HÄGERSTEN'} $.ajax({ url: POST_URL, type: 'POST', data: newValues, success: function() ... });
The newValues object has more values, but I am extracting them from the form. However, I tried to specify these values manually as newValues['name'] = 'ÄÄÄÄ'; and still cause the same problem.
The original form element of the page I am sending AJAX to contains the accept-charset="iso-8859-1" attribute. Perhaps that matters.
The target site uses Servlet/2.5 JSP/2.1 . Just conclude that this may affect.
I assume this is a problem with the encoding, and as I understand it, it should be because the Chrome extensions require the script files to be encoded in UTF-8 encoding, which probably conflicts with the site the plugin is running on and the target an AJAX page (same site) that uses ISO-8859-1 encoding, however I have no idea how to deal with this. I tried several methods to decode / encode it, and from UTF-8 to ISO-8859-1 and other tricks without success.
I tried using encodeURIComponent for my values, which only makes them that way exactly so that the form displaying the values sent via POST, for example. H%C3%84GERSTEN .
I do not have access to the website server and you cannot say if this is a problem on their part, but I would not do that.
UPDATE
Now I realized that the POST data should be sent as UTF-8! So conversion is not a problem?