달력

62025  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
반응형

Ajax에서는 기본적으로 utf-8로 통신하기에 euc-kr로 설정되어 있다면 한글이 깨집니다.

폼 html문서가 euc-kr 일때
<div id="result"></div>
<form action="./update.php" name="form1" method="post">
...
</form>
<script type="text/javascript">
$('#form1').submit(function() {
$.post('update.php', $(this).serialize(),
function(data) {
$('#result').html(data)
}
);
return false;
});
</script>


서버측 php 문서의 인코딩 환경도 euc-kr로 설정해 주어야 한글 결과가 제대로 표현됩니다.
form으로 넘겨받은 한글값은 Ajax처리로 utf-8로 넘어왔으니까 문서에 맞게 euc-kr로 바꿔주세요~
<?
header("Content-Type: text/html; charset=euc-kr);
$message=iconv("utf-8","euc-kr","$message");

echo "처리 결과 보여줄 문자열";
?>

 

반응형
Posted by 친절한 웬디양~ㅎㅎ
|