jquery ajaxで漢字を送信すると文字化けしますか?
送信ページは次の submit.htm コードです
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>欢迎</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> ... $.ajax({ type:"POST", url: "xx/add_post.php", data:'aa='+escape($('#aa').val())+'&bb='+$('#bb').val(), success: function(html){ alert('添加成功!'); } }); .... <html>
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <?php header("Content-Type:text/html;charset=utf-8"); date_default_timezone_set("PRC"); try{ $pdo=new PDO("mysql:host=localhost;dbname=acom", "root", "abcdefghi"); }catch(PDOException $e){ echo $e->getMessage(); } $stmt=$pdo->prepare("insert into acom_a(aa, bb) values(:aa, :bb)"); $stmt->execute(array(":aa"=>$_POST["aa"], ":bb"=>$_POST["bb"])); ?>