Develope/jQuery
euc-kr 환경에서 jQuery Ajax Form 한글 사용하기
친절한 웬디양~ㅎㅎ
2014. 2. 21. 09:45
반응형
Ajax에서는 기본적으로 utf-8로 통신하기에 euc-kr로 설정되어 있다면 한글이 깨집니다.
폼 html문서가 euc-kr 일때
서버측 php 문서의 인코딩 환경도 euc-kr로 설정해 주어야 한글 결과가 제대로 표현됩니다.
form으로 넘겨받은 한글값은 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>
<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 "처리 결과 보여줄 문자열";
?>
header("Content-Type: text/html; charset=euc-kr);
$message=iconv("utf-8","euc-kr","$message");
echo "처리 결과 보여줄 문자열";
?>
반응형