I've to read JSON file encoded with utf-8 charset
I use this syntax:
$http.get('resources/negozi.json',
{header : {'Content-Type' : 'application/json; charset=UTF-8'}
}).success(function(data) {
... code here
});
But, the response header is:
Content-Type:text/plain; charset=ISO-8859-1
If I try to do this with jquery:
$.ajax({
type: "GET",
url: "resources/negozi.json",
contentType: "application/json; charset=utf-8",
dataType: "json",
The request header is correct. But, the response is the same.
Content-Type:text/plain; charset=ISO-8859-1
It looks like you might need to set an Accept
header. The contentType
header applies to the stuff you're sending;
Accept: application/json;charset=UTF-8
Accept-Charset: UTF-8
so;
$.ajax({
type:"GET",
url:"resources/negozi.json",
headers: {
"Accept": "application/json;charset=utf-8",
"Accept-Charset":"charset=utf-8"
},
dataType:"json"
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With