Reputation: 1286
I am having a json file which has special characters in it. But when I make ajax call to get that file, in success callback some characters are converted to �
. I have set content-type as:
application/json;charset=UTF-8.
Below is myfile.json
content and ajax
call:
{
"image": "images/item.jpg",
"text": "there’re software products® "
}
$.ajax({
async:false,
type: "GET",
url: "JSON/myfile.json",
dataType: "json",
contentType: "application/json;charset=UTF-8",
success: function (data) {
arrayobj = data;
}
});
I tried setting encoding of json file as UTF-8
from ANSI
but still �
appear.
Upvotes: 0
Views: 948
Reputation: 623
you can value of contentType replace with
contentType:"application/x-javascript; charset:ISO-8859-1"
Upvotes: 0
Reputation: 5822
Look at the character encoding of your file. Try to convert your myfile.json
to UTF-8 if needed.
Upvotes: 1