Hi,
I'm just starting with jQuery and I have a short question about the Ajax method. I've the following code:
- $.ajax({
url: "scriptx.php",
contentType: 'application/x-www-form-urlencoded; charset=ISO-8859-1',
beforeSend: function ( xhr ) {
xhr.overrideMimeType("text/html; charset=ISO-8859-1");
},
data: { p : arg },
statusCode: {
404: function() {
alert("page not found");
}
},
success: function( data ) {
$( ".content" ).empty();
$( ".content" ).html( data);
}
}).done(function() {
// $(this).addClass("done");
});
- }
The script scriptx.php gets a parameter named 'p' and I print (echo) stuf depending on the 'p' parameter. My problem is what is shown into my browser contain funnies chars (french) such as é à è ù etc. and these chars are not printed correctly into the ".content" div. I've strange chars, including square and so on.
I tried :
contentType: 'application/x-www-form-urlencoded; charset=ISO-8859-1' but it does not works.
I tried :
beforeSend: function ( xhr ) {
xhr.overrideMimeType("text/html; charset=ISO-8859-1");
}
It does not works, too.
I tried to encode theses chars into my php scripts : it works, but, due to an nother problem I need to use Javascript. The problem is that my PHP script reads a file that containts data containing HTML tags. So the encoding (on the server PHP side) encode theses HTML tags, and I do not get the expected result. So I need to use Javascript.
Thanks in advance.