Premium support for our pure JavaScript UI components
Hi,
I'm having an issue with characters like á and ñ in the task name. They end up being unknown, question mark symbols:
charactersissue-1.png (3.67 KiB) Viewed 797 times
The server response via Ajaxhelper.fetch is fine:
charactersissue-2.png (26.56 KiB) Viewed 797 times
But then after parsing, in the data.parsedJson it's scrambled:
charactersissue-3.png (26.56 KiB) Viewed 797 times
Part of my code:
AjaxHelper.fetch(fetchUrl, {
mode : 'no-cors',
method : 'POST',
parseJson : true,
body :JSON.stringify(requestData),
headers : {
'Content-Type': 'application/json',
'Request-Source': 'XMLHTTP',
'Request-Type': 'XMLHTTP'
}
}).then(function(response) {
console.log('response');
console.log(response);
return iscloud == true ? response : response.text(); // = true
}).then(function(data) {
console.log('response to text if needed');
console.log(data);
console.log(data.parsedJson);
Am I missing an encoding setting or something?
Thank you.
Hi,
Could you please provide raw server response in clear text?
Best regards,
Tasnim
Raw server response:
{
"2UMWOL": [
{
"code": "11661",
"comments": "",
"parentwo": "",
"equipment": "ALG.000",
"priority": "P2",
"startdate": "2022-05-02 00:00:00.0",
"costcode": "",
"assignedto": "MAURICE.LAPRE",
"rstatus": "R",
"eamproject": "",
"wotype": "BRKD",
"equipmentdesc": "Gebouwen Algemeen",
"enddate": "2022-05-06 00:00:00.0",
"schedenddate": "06-MAY-2022",
"organization": "SD01",
"targetdate": "02-MAY-2022",
"name": "Test ~ñ à á !@#$%^&*()",
"requestend": "",
"requeststart": "",
"department": "*",
"class": "",
"supervisor": "",
"status": "WOP"
}
]
}
If I run this in our basic sample, it works just fine
AjaxHelper.fetch('../_datasets/launch-saas.json', {
mode : 'no-cors',
method : 'POST',
parseJson : true,
body : JSON.stringify({ foo : 'bar' }),
headers : {
'Content-Type' : 'application/json',
'Request-Source' : 'XMLHTTP',
'Request-Type' : 'XMLHTTP'
}
}).then(function(data) {
console.log('response to text if needed');
console.log(data);
console.log(data.parsedJson);
});
Output in image, so must be something on your server.
Attachments
Screenshot 2022-05-07 at 14.48.43.png (273.56 KiB) Viewed 767 times
Thanks for investigating. But how can it be something on my server when my server responds correctly? And only after parsing the response data via the Ajaxhelper.fetch, the weird characters show up?
It's indeed
Content-Type: application/json;charset=ISO-8859-1
. So, characters seem the same but aren't, I assume.
I have requested to change this to utf-8, assume that should solve the issue.
Thanks for that hint, Mats!
Glad it's resolved