<!-- <%@ // page contentType="text/plain; charset=utf-8" %>
jsp 일경우 언어셋 설정
<%
/*
request.setCharacterEncoding("utf-8");
String name = request.getParameter("name");
*/
%> utf-8 로 인코딩된 파라미터 받기
<?
/*
$name = $_POST['name'];
$name = iconv("utf-8","euc-kr",$name);
//utf-8 로 파라미터를 받아서 euc-kr 에서 쓸때
*/
?>
<? //header("Content-Type: text/plain: charset=UTF-8"); ?>
-->
<!DOCTYPE HTML>
<html lang="ko">
<head>
<meta charset="utf-8">
<title> GNUJ </title>
<script type="text/javascript" >
var hR = null;
var parms = null;
parms = "name=" + encodeURIComponent("정지현");//한글 UTF-8인코딩 변환
function loadGet(url,params){
hR = new XMLHttpRequest();
hR.onreadystatechange = returnResult;
hR.open("GET",url+"?"+params,true);
hR.send(null);
}
function loadPost(url,params){
hR = new XMLHttpRequest();
hR.onreadystatechange = returnResult;
hR.open("POST",url,true);
hR.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
hR.send(params);
}
function returnResult(){
if( hR.readyState == 4 ){
if( hR.status == 200 ){
alert("요청 성공 200 : " + hR.responseText );
}else if( hR.status == 403 ){
alert("접근 거부 : " + hR.status );
}else if( hR.status == 404 ){
alert("페이지 없음 : " + hR.status );
}else if( hR.status == 500 ){
alert("서버 오류 : " + hR.status );
}else{
alert("통신 에러" + hR.status );
}
}else if( hR.readyState == 1 || hR.readyState == 2 || hR.readyState == 3 ){
//alert("통신 중");
}else{
alert("통신 에러" + hR.readyState );
}
}
</script>
</head>
<body>
<div><input type="button" value="get.php" onclick="loadGet('get.php','name=정지현&email=guslghfud@gmail.com');" /></div>
<div><input type="button" value="post.php" onclick="loadPost('post.php','name=정지현&email=guslghfud@gmail.com');" /></div>
</body>
</html>