클라이언트 측에서 GET으로 요청해서 서버에서 처리할수 있는방법없나요?
아무리 구글링해도.,. 클라이언트에서 전송한 get변수를 받을수 있는 방법이 없네요...
댓글 3개
13년 전
express.js 에서 req 부분을 처리하시면 됩니다.
express.js 가 node에서 http를 쉽게 처리할수 있도록 해주는 라이브러리입니다.
app.get("/page/", function(req, res) {
console.log('request userid : ' + req.params.userid);
}
대충 이런식
express.js 가 node에서 http를 쉽게 처리할수 있도록 해주는 라이브러리입니다.
app.get("/page/", function(req, res) {
console.log('request userid : ' + req.params.userid);
}
대충 이런식
Terrorboy
13년 전
아... 전송방식을 바꿔야하나보군요...
현제 전송방식은
<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>
입니다 ㅎㅎ
Terrorboy
13년 전
http://stackoverflow.com/questions/6866751/how-to-combine-two-node-js-app-server-together
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 4230 |
|
13년 전 | 1555 | |
| 4229 | 13년 전 | 1113 | ||
| 4228 | 13년 전 | 2106 | ||
| 4227 | 13년 전 | 797 | ||
| 4226 |
|
13년 전 | 815 | |
| 4225 |
천국의눈믈
|
13년 전 | 628 | |
| 4224 |
visualp
|
13년 전 | 1434 | |
| 4223 |
visualp
|
13년 전 | 1046 | |
| 4222 |
visualp
|
13년 전 | 765 | |
| 4221 |
visualp
|
13년 전 | 5298 | |
| 4220 | 13년 전 | 1904 | ||
| 4219 | 13년 전 | 1146 | ||
| 4218 | 13년 전 | 641 | ||
| 4217 | 13년 전 | 9438 | ||
| 4216 | 13년 전 | 1553 | ||
| 4215 |
|
13년 전 | 572 | |
| 4214 | 13년 전 | 561 | ||
| 4213 | 13년 전 | 1426 | ||
| 4212 |
visualp
|
13년 전 | 2008 | |
| 4211 | 14년 전 | 1551 | ||
| 4210 | 14년 전 | 821 | ||
| 4209 |
|
14년 전 | 2048 | |
| 4208 | 14년 전 | 2052 | ||
| 4207 | 14년 전 | 3000 | ||
| 4206 | 14년 전 | 1097 | ||
| 4205 |
SGFlash
|
14년 전 | 1285 | |
| 4204 | 14년 전 | 808 | ||
| 4203 | 14년 전 | 893 | ||
| 4202 | 14년 전 | 2114 | ||
| 4201 | 14년 전 | 906 | ||
| 4200 | 14년 전 | 2377 | ||
| 4199 | 14년 전 | 627 | ||
| 4198 |
visualp
|
14년 전 | 3504 | |
| 4197 |
visualp
|
14년 전 | 724 | |
| 4196 | 14년 전 | 2084 | ||
| 4195 |
미사카10777호
|
14년 전 | 3467 | |
| 4194 |
senseme
|
14년 전 | 772 | |
| 4193 | 14년 전 | 949 | ||
| 4192 | 14년 전 | 1305 | ||
| 4191 |
DreamT
|
14년 전 | 800 | |
| 4190 |
onlymilk74
|
14년 전 | 1310 | |
| 4189 | 14년 전 | 1248 | ||
| 4188 | 14년 전 | 1370 | ||
| 4187 | 14년 전 | 1104 | ||
| 4186 |
|
14년 전 | 728 | |
| 4185 | 14년 전 | 1193 | ||
| 4184 | 14년 전 | 1168 | ||
| 4183 |
visualp
|
14년 전 | 1044 | |
| 4182 |
visualp
|
14년 전 | 610 | |
| 4181 |
|
14년 전 | 618 | |
| 4180 |
techer
|
14년 전 | 951 | |
| 4179 | 14년 전 | 523 | ||
| 4178 | 14년 전 | 3075 | ||
| 4177 | 14년 전 | 598 | ||
| 4176 | 14년 전 | 945 | ||
| 4175 | 14년 전 | 596 | ||
| 4174 |
|
14년 전 | 630 | |
| 4173 |
|
14년 전 | 1854 | |
| 4172 |
|
14년 전 | 907 | |
| 4171 | 14년 전 | 1393 | ||
| 4170 | 14년 전 | 662 | ||
| 4169 | 14년 전 | 1289 | ||
| 4168 | 14년 전 | 1771 | ||
| 4167 | 14년 전 | 809 | ||
| 4166 | 14년 전 | 1319 | ||
| 4165 |
visualp
|
14년 전 | 809 | |
| 4164 | 14년 전 | 1176 | ||
| 4163 | 14년 전 | 2601 | ||
| 4162 | 14년 전 | 654 | ||
| 4161 |
onlymilk74
|
14년 전 | 4787 | |
| 4160 | 14년 전 | 679 | ||
| 4159 | 14년 전 | 868 | ||
| 4158 | 14년 전 | 705 | ||
| 4157 | 14년 전 | 3389 | ||
| 4156 | 14년 전 | 504 | ||
| 4155 | 14년 전 | 836 | ||
| 4154 | 14년 전 | 1138 | ||
| 4153 | 14년 전 | 1141 | ||
| 4152 | 14년 전 | 634 | ||
| 4151 | 14년 전 | 1239 | ||
| 4150 | 14년 전 | 721 | ||
| 4149 | 14년 전 | 622 | ||
| 4148 |
쉽다zzz
|
14년 전 | 2253 | |
| 4147 | 14년 전 | 950 | ||
| 4146 | 14년 전 | 575 | ||
| 4145 | 14년 전 | 577 | ||
| 4144 | 14년 전 | 1612 | ||
| 4143 | 14년 전 | 766 | ||
| 4142 | 14년 전 | 1173 | ||
| 4141 | 14년 전 | 1160 | ||
| 4140 |
|
14년 전 | 1768 | |
| 4139 |
visualp
|
14년 전 | 1844 | |
| 4138 |
visualp
|
14년 전 | 1113 | |
| 4137 | 14년 전 | 769 | ||
| 4136 | 14년 전 | 709 | ||
| 4135 | 14년 전 | 958 | ||
| 4134 | 14년 전 | 1114 | ||
| 4133 | 14년 전 | 2527 | ||
| 4132 | 14년 전 | 575 | ||
| 4131 | 14년 전 | 891 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기