When posting data to my google spreadsheet web app script, Google strips away the norwegian characters from the postdata. e.postData.contents is correct, but e.parameters is incorrect. See the code example below. When you press send, you will see that e.parameters and e.postData.contents returned by the google script are different.
To reproduce the problem with your own google spreadsheet web app:
- Make a copy of my google spreadsheet
- In the spreadsheet, select Tools->script editor
- In the script editor, select Publish->Deploy as web app
- In the dialog that opens, set "Who has access to the app" to "Anyone, even anonymous". Finally, press "Deploy".
- You are now told that you need to give permissions to the script. Press "Review permissions". A message tells you that you should only allow this script to run if you trust the developer. Click on "Advanced" and click on the link at the bootom. Click allow.
- In the new dialog that appears, copy the address of the "Current web app url".
- In the code sample, replace the variable actionscript with the address you copied in step 6.
var actionScript = "https://script.google.com/macros/s/AKfycbxW1qHugD1K4adTjGAEt1KqbcbAn1LlaCoWx6GtlNdsNO_E-rTO/exec";
$(document).ready(function(){
var sendButton = $("#send");
if(sendButton != null)
{
sendButton.click(handleSend);
}
});
function handleSend(event) {
var data = $("#name").val();
console.log(data);
var postData = "name="+data;
console.log(postData);
request = $.ajax({
url: actionScript,
type: "post",
data: postData,
beforeSend: function () {
console.log("Loading");
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
},
success: function (result) {
console.log("success");
var s = "<p>e.parameters=" + result.data + "</p><p>e.postData.contents="+result.postdata+"</p>"
$("#result").html(s);
debugger;
},
complete: function () {
console.log('Finished all tasks');
}
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!doctype html>
<html lang="no">
<head>
<meta charset="utf-8">
</head>
<body>
<input id="name" type="text" value="GÅGHØHRÆR" size="50"/>
<button id="send">Send</button>
<div id="result">
</div>
</body>
</html>