클라이언트 측에서 GET으로 요청해서 서버에서 처리할수 있는방법없나요?
아무리 구글링해도.,. 클라이언트에서 전송한 get변수를 받을수 있는 방법이 없네요...
댓글 3개
아... 전송방식을 바꿔야하나보군요...
현제 전송방식은
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=euc-kr" />
<title>Ajax Test</title>
<script language="Javascript">
/*http://blog.naver.com/ctlim2?Redirect=Log&logNo=50044001483*/
/**
* Ajax Call
* @param strURL : call cgi
* @param strFunction : callBack Function
* @param strArgument : argument
*/
function xmlhttpPost(strURL, strArgument, callFunction) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if(window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if(window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('GET', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
self.xmlHttpReq.onreadystatechange = function() {
if(self.xmlHttpReq.readyState == 0) { // 아직 초기화 안됨
}
else if(self.xmlHttpReq.readyState == 1) { // 읽는 중
}
else if(self.xmlHttpReq.readyState == 2) { // 읽기 완료
}
else if(self.xmlHttpReq.readyState == 3) { // 작업 중
}
else if(self.xmlHttpReq.readyState == 4) { // 작업완료
callFunction(self.xmlHttpReq);
}
}
self.xmlHttpReq.send(strArgument);
}
/**
* callBack Json
*/
function callBackJson(in_Data){
// JSON 일 때
var arrayDoc = in_Data.responseText;
eval("var jsonData ="+arrayDoc);
//var text = jsonData['id'];
//document.getElementById("result").innerHTML = text;
document.getElementById("result").innerHTML = in_Data.responseText
}
/**
* Ajax Json을 호출 한다.
*/
function callJson()
{
var form = document.forms['f1'];
var id = form.id.value;
var a = form.a.value;
var b = form.b.value;
var id = encodeURIComponent(id);
var a = encodeURIComponent(a);
var b = encodeURIComponent(b);
xmlhttpPost('http://terrorboy.net:40000', "id="+id+"&a="+a+"&b="+b, callBackJson);
}
</script>
</head>
<body>
<form name="f1" accept-charset="">
id: <input id="id" name="id" type="text" value="id" /> <br />
a: <input id="a" name="a" type="text" value="a" /> <br />
b: <input id="b" name="b" type="text" value="b" /> <br />
<input value="Json" type="button" onclick="JavaScript:callJson()" />
<div id="result"></div>
</form>
</body>
</html>
입니다 ㅎㅎ
현제 전송방식은
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=euc-kr" />
<title>Ajax Test</title>
<script language="Javascript">
/*http://blog.naver.com/ctlim2?Redirect=Log&logNo=50044001483*/
/**
* Ajax Call
* @param strURL : call cgi
* @param strFunction : callBack Function
* @param strArgument : argument
*/
function xmlhttpPost(strURL, strArgument, callFunction) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if(window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if(window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('GET', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
self.xmlHttpReq.onreadystatechange = function() {
if(self.xmlHttpReq.readyState == 0) { // 아직 초기화 안됨
}
else if(self.xmlHttpReq.readyState == 1) { // 읽는 중
}
else if(self.xmlHttpReq.readyState == 2) { // 읽기 완료
}
else if(self.xmlHttpReq.readyState == 3) { // 작업 중
}
else if(self.xmlHttpReq.readyState == 4) { // 작업완료
callFunction(self.xmlHttpReq);
}
}
self.xmlHttpReq.send(strArgument);
}
/**
* callBack Json
*/
function callBackJson(in_Data){
// JSON 일 때
var arrayDoc = in_Data.responseText;
eval("var jsonData ="+arrayDoc);
//var text = jsonData['id'];
//document.getElementById("result").innerHTML = text;
document.getElementById("result").innerHTML = in_Data.responseText
}
/**
* Ajax Json을 호출 한다.
*/
function callJson()
{
var form = document.forms['f1'];
var id = form.id.value;
var a = form.a.value;
var b = form.b.value;
var id = encodeURIComponent(id);
var a = encodeURIComponent(a);
var b = encodeURIComponent(b);
xmlhttpPost('http://terrorboy.net:40000', "id="+id+"&a="+a+"&b="+b, callBackJson);
}
</script>
</head>
<body>
<form name="f1" accept-charset="">
id: <input id="id" name="id" type="text" value="id" /> <br />
a: <input id="a" name="a" type="text" value="a" /> <br />
b: <input id="b" name="b" type="text" value="b" /> <br />
<input value="Json" type="button" onclick="JavaScript:callJson()" />
<div id="result"></div>
</form>
</body>
</html>
입니다 ㅎㅎ
게시글 목록
| 번호 | 제목 |
|---|---|
| 12487 |
PHP
pc 모바일 체크
|
| 12486 |
PHP
계정 사용량(용량) 확인
|
| 380 | |
| 12484 | |
| 12483 |
MySQL
소수점 반올림 버림
|
| 376 | |
| 12482 | |
| 12481 |
PHP
에러 로그파일 생성하기
|
| 12479 | |
| 12478 | |
| 12477 |
PHP
후이즈검색 하기 입니다.
|
| 12476 |
PHP
그래프 그리기 입니다.
|
| 12475 |
JavaScript
자바스크립트로 구현한 number_format() 입니다.
|
| 12474 |
JavaScript
금액 관련 숫자를 한글로 변환하기 입니다.
|
| 12473 |
PHP
PHP 날짜 계산 관련 함수
|
| 12472 |
jQuery
jQuery 1.x와 2.x 버전 동시에 사용하기
|
| 12471 | |
| 12470 | |
| 12469 |
JavaScript
사업자 등록번호 검사하기 입니다.
|
| 371 | |
| 12468 | |
| 12467 |
JavaScript
항상 같은곳에 광고창 만들기 입니다.
|
| 12466 |
JavaScript
부메뉴 나오게 하기 입니다.
|
| 12465 |
JavaScript
특정문자 제거하기 입니다.
|
| 12464 |
JavaScript
휴대폰번호 검사 하기 입니다.
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기