클라이언트 측에서 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
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 4130 |
진정한승리v
|
13년 전 | 1054 | |
| 4129 | 13년 전 | 1421 | ||
| 4128 |
onlymilk74
|
13년 전 | 612 | |
| 4127 | 13년 전 | 529 | ||
| 4126 |
visualp
|
13년 전 | 1244 | |
| 4125 |
visualp
|
13년 전 | 1579 | |
| 4124 | 13년 전 | 1650 | ||
| 4123 | 13년 전 | 819 | ||
| 4122 |
visualp
|
13년 전 | 633 | |
| 4121 |
visualp
|
13년 전 | 1788 | |
| 4120 |
visualp
|
13년 전 | 855 | |
| 4119 |
visualp
|
13년 전 | 1229 | |
| 4118 |
그래픽노블
|
13년 전 | 682 | |
| 4117 |
visualp
|
13년 전 | 741 | |
| 4116 | 13년 전 | 731 | ||
| 4115 |
visualp
|
13년 전 | 823 | |
| 4114 |
onlymilk74
|
13년 전 | 4623 | |
| 4113 | 13년 전 | 730 | ||
| 4112 |
그래픽노블
|
13년 전 | 850 | |
| 4111 | 13년 전 | 1505 | ||
| 4110 | 13년 전 | 673 | ||
| 4109 | 13년 전 | 467 | ||
| 4108 | 13년 전 | 841 | ||
| 4107 | 13년 전 | 2112 | ||
| 4106 | 13년 전 | 1584 | ||
| 4105 |
onlymilk74
|
13년 전 | 1406 | |
| 4104 | 13년 전 | 2836 | ||
| 4103 | 14년 전 | 1947 | ||
| 4102 | 14년 전 | 903 | ||
| 4101 | 14년 전 | 970 | ||
| 4100 | 14년 전 | 926 | ||
| 4099 | 14년 전 | 1023 | ||
| 4098 |
Lonnie
|
14년 전 | 517 | |
| 4097 | 14년 전 | 820 | ||
| 4096 | 14년 전 | 970 | ||
| 4095 | 14년 전 | 2521 | ||
| 4094 | 14년 전 | 836 | ||
| 4093 | 14년 전 | 565 | ||
| 4092 |
|
14년 전 | 586 | |
| 4091 | 14년 전 | 2934 | ||
| 4090 | 14년 전 | 721 | ||
| 4089 |
|
14년 전 | 1437 | |
| 4088 | 14년 전 | 1439 | ||
| 4087 | 14년 전 | 634 | ||
| 4086 | 14년 전 | 1356 | ||
| 4085 | 14년 전 | 747 | ||
| 4084 | 14년 전 | 851 | ||
| 4083 | 14년 전 | 1815 | ||
| 4082 | 14년 전 | 1520 | ||
| 4081 | 14년 전 | 2120 | ||
| 4080 |
onlymilk74
|
14년 전 | 854 | |
| 4079 | 14년 전 | 740 | ||
| 4078 | 14년 전 | 2124 | ||
| 4077 |
DreamT
|
14년 전 | 755 | |
| 4076 | 14년 전 | 861 | ||
| 4075 | 14년 전 | 1974 | ||
| 4074 | 14년 전 | 991 | ||
| 4073 | 14년 전 | 900 | ||
| 4072 |
onlymilk74
|
14년 전 | 649 | |
| 4071 | 14년 전 | 896 | ||
| 4070 | 14년 전 | 1911 | ||
| 4069 | 14년 전 | 476 | ||
| 4068 | 14년 전 | 2436 | ||
| 4067 | 14년 전 | 802 | ||
| 4066 | 14년 전 | 509 | ||
| 4065 | 14년 전 | 514 | ||
| 4064 | 14년 전 | 774 | ||
| 4063 | 14년 전 | 683 | ||
| 4062 | 14년 전 | 579 | ||
| 4061 | 14년 전 | 1072 | ||
| 4060 | 14년 전 | 510 | ||
| 4059 | 14년 전 | 1190 | ||
| 4058 | 14년 전 | 1557 | ||
| 4057 | 14년 전 | 519 | ||
| 4056 |
|
14년 전 | 653 | |
| 4055 |
SGFlash
|
14년 전 | 507 | |
| 4054 |
Priere
|
14년 전 | 658 | |
| 4053 | 14년 전 | 1085 | ||
| 4052 | 14년 전 | 781 | ||
| 4051 | 14년 전 | 906 | ||
| 4050 | 14년 전 | 725 | ||
| 4049 | 14년 전 | 863 | ||
| 4048 |
내꿈은대통령
|
14년 전 | 456 | |
| 4047 |
visualp
|
14년 전 | 1265 | |
| 4046 |
visualp
|
14년 전 | 607 | |
| 4045 |
visualp
|
14년 전 | 1369 | |
| 4044 | 14년 전 | 8124 | ||
| 4043 | 14년 전 | 745 | ||
| 4042 | 14년 전 | 1592 | ||
| 4041 | 14년 전 | 1317 | ||
| 4040 | 14년 전 | 1591 | ||
| 4039 | 14년 전 | 1927 | ||
| 4038 | 14년 전 | 526 | ||
| 4037 |
sider
|
14년 전 | 670 | |
| 4036 | 14년 전 | 6461 | ||
| 4035 | 14년 전 | 652 | ||
| 4034 | 14년 전 | 584 | ||
| 4033 |
techer
|
14년 전 | 1731 | |
| 4032 | 14년 전 | 639 | ||
| 4031 | 14년 전 | 634 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기