클라이언트 측에서 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
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 4430 | 13년 전 | 825 | ||
| 4429 | 13년 전 | 1149 | ||
| 4428 | 13년 전 | 1940 | ||
| 4427 | 13년 전 | 1059 | ||
| 4426 | 13년 전 | 521 | ||
| 4425 | 13년 전 | 9876 | ||
| 4424 |
|
13년 전 | 841 | |
| 4423 |
|
13년 전 | 708 | |
| 4422 |
aequum
|
13년 전 | 1287 | |
| 4421 | 13년 전 | 2411 | ||
| 4420 | 13년 전 | 1204 | ||
| 4419 | 13년 전 | 889 | ||
| 4418 |
한번잘해보자
|
13년 전 | 671 | |
| 4417 | 13년 전 | 1579 | ||
| 4416 | 13년 전 | 871 | ||
| 4415 | 13년 전 | 2249 | ||
| 4414 | 13년 전 | 679 | ||
| 4413 | 13년 전 | 677 | ||
| 4412 | 13년 전 | 818 | ||
| 4411 | 13년 전 | 1437 | ||
| 4410 |
|
13년 전 | 697 | |
| 4409 | 13년 전 | 2165 | ||
| 4408 |
visualp
|
13년 전 | 531 | |
| 4407 |
visualp
|
13년 전 | 3087 | |
| 4406 |
visualp
|
13년 전 | 3253 | |
| 4405 |
visualp
|
13년 전 | 3152 | |
| 4404 |
visualp
|
13년 전 | 2977 | |
| 4403 |
|
13년 전 | 666 | |
| 4402 |
gender
|
13년 전 | 622 | |
| 4401 | 13년 전 | 1112 | ||
| 4400 |
aequum
|
13년 전 | 1380 | |
| 4399 | 13년 전 | 586 | ||
| 4398 | 13년 전 | 669 | ||
| 4397 |
|
13년 전 | 580 | |
| 4396 |
aequum
|
13년 전 | 4660 | |
| 4395 |
|
13년 전 | 554 | |
| 4394 |
aequum
|
13년 전 | 4931 | |
| 4393 |
|
13년 전 | 1265 | |
| 4392 | 13년 전 | 1053 | ||
| 4391 |
mirrV
|
13년 전 | 531 | |
| 4390 |
파워웹프로
|
13년 전 | 703 | |
| 4389 | 13년 전 | 1224 | ||
| 4388 |
Coding
|
13년 전 | 702 | |
| 4387 |
aequum
|
13년 전 | 1360 | |
| 4386 | 13년 전 | 868 | ||
| 4385 | 13년 전 | 722 | ||
| 4384 | 13년 전 | 786 | ||
| 4383 | 13년 전 | 2899 | ||
| 4382 | 13년 전 | 606 | ||
| 4381 | 13년 전 | 1171 | ||
| 4380 | 13년 전 | 803 | ||
| 4379 |
|
13년 전 | 746 | |
| 4378 | 13년 전 | 663 | ||
| 4377 | 13년 전 | 3300 | ||
| 4376 |
aequum
|
13년 전 | 1214 | |
| 4375 |
클로로다인
|
13년 전 | 648 | |
| 4374 |
DDFACTORY
|
13년 전 | 719 | |
| 4373 |
까탈스런ET
|
13년 전 | 705 | |
| 4372 | 13년 전 | 802 | ||
| 4371 | 13년 전 | 566 | ||
| 4370 |
|
13년 전 | 644 | |
| 4369 |
프리프리닷
|
13년 전 | 1302 | |
| 4368 | 13년 전 | 3166 | ||
| 4367 |
soing
|
13년 전 | 1575 | |
| 4366 |
|
13년 전 | 684 | |
| 4365 |
|
13년 전 | 622 | |
| 4364 |
|
13년 전 | 757 | |
| 4363 |
|
13년 전 | 622 | |
| 4362 |
|
13년 전 | 727 | |
| 4361 |
|
13년 전 | 842 | |
| 4360 |
|
13년 전 | 650 | |
| 4359 |
|
13년 전 | 3124 | |
| 4358 |
|
13년 전 | 3038 | |
| 4357 | 13년 전 | 841 | ||
| 4356 | 13년 전 | 1340 | ||
| 4355 | 13년 전 | 965 | ||
| 4354 | 13년 전 | 815 | ||
| 4353 | 13년 전 | 3373 | ||
| 4352 | 13년 전 | 2374 | ||
| 4351 | 13년 전 | 1960 | ||
| 4350 |
|
13년 전 | 1877 | |
| 4349 | 13년 전 | 650 | ||
| 4348 |
aequum
|
13년 전 | 1410 | |
| 4347 | 13년 전 | 659 | ||
| 4346 |
|
13년 전 | 565 | |
| 4345 | 13년 전 | 597 | ||
| 4344 |
aequum
|
13년 전 | 1003 | |
| 4343 |
|
13년 전 | 1038 | |
| 4342 |
aequum
|
13년 전 | 1630 | |
| 4341 | 13년 전 | 802 | ||
| 4340 |
2번호랑이
|
13년 전 | 1002 | |
| 4339 |
|
13년 전 | 1168 | |
| 4338 | 13년 전 | 1164 | ||
| 4337 | 13년 전 | 519 | ||
| 4336 |
aequum
|
13년 전 | 1705 | |
| 4335 | 13년 전 | 888 | ||
| 4334 | 13년 전 | 1184 | ||
| 4333 |
Sturmvogel
|
13년 전 | 961 | |
| 4332 |
aequum
|
13년 전 | 1281 | |
| 4331 |
aequum
|
13년 전 | 1397 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기