I wrote a js script to post form data to my php backend. But the Textfield would receive it with a false encoding.
Here is my meta tag for this site:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Heres my textarea:
<textarea id="orderlistlieferanschrift" style="width:294px; height:80px; resize:none;"></textarea>
Here is my php script:
header('Content-typ: content="text/html; charset=UTF-8');
$postdata = $_POST["postData"];
error_log($postdata);
The Data is collected as follows:
var Lieferanschrift = $("#orderlistlieferanschrift").val();
aOrderInformations[9] = Lieferanschrift;
Here is my ajax request:
var postData = JSON.stringify(aOrderInformations);
if(!ajaxload2) {
//alert(postData);
ajaxload2 = true;
$.ajax({
type : 'POST',
url : 'share/content/helper/writeorderdata.php',
cache: false,
dataType : 'json',
data: {postData:postData},
success: function() {
ajaxload2 = false;
alert("erledigt");
}
});
}
In the server log the data where displayed as follows:
"Zentrale Oberursel\\nGablonzer Stra\xc3\x9fe 35\\n61440 Oberursel"
When I use the option data-Typ in jquery ajax an play with them an them the data won´t send.
In case you must be sure every thing is in order.... 1: Table DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; 2: adding utf-8 in your html head section:
Try This after connecting to the MySQL Database...
Instead of using
header('Content-typ: content="text/html; charset=UTF-8');
use the following
mysql_query("SET NAMES 'utf8'");
Adding to
AddDefaultCharset utf-8 to the httpd.conf (apache config file?)
Or maybe is it the mistyped
header('Content-typ: content="text/html; charset=UTF-8');
to
header('Content-type: content="text/html; charset=UTF-8');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.