클라이언트 측에서 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
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8230 | 9년 전 | 71 | ||
| 8229 | 9년 전 | 69 | ||
| 8228 |
커네드커네드
|
9년 전 | 112 | |
| 8227 | 9년 전 | 124 | ||
| 8226 | 9년 전 | 161 | ||
| 8225 | 9년 전 | 149 | ||
| 8224 | 9년 전 | 147 | ||
| 8223 | 9년 전 | 113 | ||
| 8222 |
|
9년 전 | 186 | |
| 8221 | 9년 전 | 90 | ||
| 8220 | 9년 전 | 102 | ||
| 8219 | 9년 전 | 99 | ||
| 8218 | 9년 전 | 139 | ||
| 8217 |
star3840
|
9년 전 | 113 | |
| 8216 | 9년 전 | 160 | ||
| 8215 | 9년 전 | 111 | ||
| 8214 | 9년 전 | 226 | ||
| 8213 | 9년 전 | 159 | ||
| 8212 | 9년 전 | 82 | ||
| 8211 | 9년 전 | 242 | ||
| 8210 | 9년 전 | 244 | ||
| 8209 | 9년 전 | 335 | ||
| 8208 | 9년 전 | 217 | ||
| 8207 | 9년 전 | 225 | ||
| 8206 |
|
9년 전 | 186 | |
| 8205 | 9년 전 | 169 | ||
| 8204 | 9년 전 | 132 | ||
| 8203 | 9년 전 | 232 | ||
| 8202 | 9년 전 | 139 | ||
| 8201 | 9년 전 | 181 | ||
| 8200 | 9년 전 | 163 | ||
| 8199 | 9년 전 | 213 | ||
| 8198 | 9년 전 | 174 | ||
| 8197 | 9년 전 | 167 | ||
| 8196 | 9년 전 | 556 | ||
| 8195 | 9년 전 | 155 | ||
| 8194 | 9년 전 | 280 | ||
| 8193 | 9년 전 | 155 | ||
| 8192 | 9년 전 | 188 | ||
| 8191 | 9년 전 | 141 | ||
| 8190 | 9년 전 | 127 | ||
| 8189 | 9년 전 | 189 | ||
| 8188 | 9년 전 | 128 | ||
| 8187 | 9년 전 | 141 | ||
| 8186 | 9년 전 | 141 | ||
| 8185 | 9년 전 | 309 | ||
| 8184 | 9년 전 | 108 | ||
| 8183 | 9년 전 | 324 | ||
| 8182 | 9년 전 | 166 | ||
| 8181 | 9년 전 | 130 | ||
| 8180 | 9년 전 | 692 | ||
| 8179 | 9년 전 | 487 | ||
| 8178 | 9년 전 | 310 | ||
| 8177 |
kiplayer
|
9년 전 | 318 | |
| 8176 | 9년 전 | 352 | ||
| 8175 | 9년 전 | 219 | ||
| 8174 | 9년 전 | 243 | ||
| 8173 | 9년 전 | 342 | ||
| 8172 | 9년 전 | 195 | ||
| 8171 | 9년 전 | 184 | ||
| 8170 | 9년 전 | 297 | ||
| 8169 |
커네드커네드
|
9년 전 | 260 | |
| 8168 | 9년 전 | 320 | ||
| 8167 | 9년 전 | 320 | ||
| 8166 | 9년 전 | 237 | ||
| 8165 | 9년 전 | 166 | ||
| 8164 | 9년 전 | 302 | ||
| 8163 | 9년 전 | 284 | ||
| 8162 | 9년 전 | 298 | ||
| 8161 | 9년 전 | 297 | ||
| 8160 |
|
9년 전 | 489 | |
| 8159 | 9년 전 | 427 | ||
| 8158 | 9년 전 | 248 | ||
| 8157 | 9년 전 | 375 | ||
| 8156 | 9년 전 | 279 | ||
| 8155 | 9년 전 | 251 | ||
| 8154 |
00년생용띠
|
9년 전 | 599 | |
| 8153 | 9년 전 | 229 | ||
| 8152 |
|
9년 전 | 408 | |
| 8151 | 9년 전 | 408 | ||
| 8150 | 9년 전 | 498 | ||
| 8149 |
Jangfolk
|
9년 전 | 348 | |
| 8148 | 9년 전 | 169 | ||
| 8147 | 9년 전 | 372 | ||
| 8146 | 9년 전 | 435 | ||
| 8145 | 9년 전 | 379 | ||
| 8144 | 9년 전 | 345 | ||
| 8143 | 9년 전 | 192 | ||
| 8142 | 9년 전 | 425 | ||
| 8141 | 9년 전 | 380 | ||
| 8140 | 9년 전 | 928 | ||
| 8139 | 9년 전 | 260 | ||
| 8138 |
전갈자리남자
|
9년 전 | 387 | |
| 8137 | 9년 전 | 395 | ||
| 8136 | 9년 전 | 744 | ||
| 8135 |
|
9년 전 | 794 | |
| 8134 |
PlayPixel
|
9년 전 | 515 | |
| 8133 |
|
9년 전 | 433 | |
| 8132 | 9년 전 | 447 | ||
| 8131 | 9년 전 | 811 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기