I am having problems with ie. In the json formated file I have:
,{“id”: “33”,”re”: “Maranhão”},{“id”: “33”,”re”: “Mato Grosso”},{“id”: “33”,”re”: “Mato Grosso do Sul”},{“id”: “33”,”re”: “Minas Gerais”},{“id”: “33”,”re”: “Paraíba”},{“id”: “33”,”re”: “Paraná”},{“id”: “33”,”re”: “Paro”},{“id”: “33”,”re”: “Pernambuco”},{“id”: “33”,”re”: “Piauí”},{“id”: “33”,”re”: “Rio de Janeiro”},{“id”: “33”,”re”: “Rio Grande do Norte”},{“id”: “33”,”re”: “Rio Grande do Sul”},{“id”: “33”,”re”: “Rondônia”},{“id”: “33”,”re”: “Roraima”},{“id”: “33”,”re”: “Santa Catarina”},{“id”: “33”,”re”: “São Paulo”},
FF, Chrome, Safari and Opera no problem. IE having problems with the special characters.
After doing a lot of searching someone that seemed to have the same problem got told to add:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
So thats what I did but still no go. Here is my code. Obviously it works. Adding just in case.
function GetRegions(CoID)
{
var i=0;
$.ajax({
type: "GET",
url: "http://localhost/JSONFiles/cregions.json",
async: false,
dataType: "json",
success: function(data){
$(data).each(function(){
if (this.id==CoID)
{
if (i==0)
{
$('#st_Region').find('option').remove(0).end().append('<option value="0">Select Your Region</option>').val('0');
}
i++;
$('#st_Region').append('<option value="'+this.re+'">'+this.re+'</option>');
};
});
if (i==0)
{
$('#st_Region').find('option').remove(0).end().append('<option value="1">No Regions For This Country</option>').val('1');
};
i=0;
}
});
};
Any help would be creatly appreciated. Thank you.
Try using Content type for JSON as
"application/json"Also, add an error function and see what the error is. This should take you to the error directly.
Also, why do you end your
if blockswith a;? Though it won’t result in error( as;is a legal empty statement), it might introduceundesired featuresand cause headache.