클라이언트 측에서 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
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7330 | 11년 전 | 1710 | ||
| 7329 | 11년 전 | 953 | ||
| 7328 | 11년 전 | 2245 | ||
| 7327 | 11년 전 | 1737 | ||
| 7326 | 11년 전 | 3836 | ||
| 7325 | 11년 전 | 2301 | ||
| 7324 | 11년 전 | 4537 | ||
| 7323 |
호식이와미돌
|
11년 전 | 1322 | |
| 7322 |
호식이와미돌
|
11년 전 | 1167 | |
| 7321 | 11년 전 | 1812 | ||
| 7320 | 11년 전 | 1786 | ||
| 7319 | 11년 전 | 1343 | ||
| 7318 |
|
11년 전 | 998 | |
| 7317 |
멋진남자임
|
11년 전 | 1643 | |
| 7316 |
잘살아보자
|
11년 전 | 1010 | |
| 7315 | 11년 전 | 1134 | ||
| 7314 | 11년 전 | 1367 | ||
| 7313 |
잘살아보자
|
11년 전 | 1142 | |
| 7312 | 11년 전 | 900 | ||
| 7311 |
사랑한데이
|
11년 전 | 2103 | |
| 7310 |
잘살아보자
|
11년 전 | 1913 | |
| 7309 |
잘살아보자
|
11년 전 | 3073 | |
| 7308 |
잘살아보자
|
11년 전 | 1030 | |
| 7307 |
잘살아보자
|
11년 전 | 793 | |
| 7306 | 11년 전 | 895 | ||
| 7305 |
잘살아보자
|
11년 전 | 2773 | |
| 7304 | 11년 전 | 1061 | ||
| 7303 | 11년 전 | 1253 | ||
| 7302 | 11년 전 | 768 | ||
| 7301 | 11년 전 | 1547 | ||
| 7300 |
mijaya
|
11년 전 | 1519 | |
| 7299 | 11년 전 | 938 | ||
| 7298 | 11년 전 | 1120 | ||
| 7297 | 11년 전 | 796 | ||
| 7296 | 11년 전 | 763 | ||
| 7295 | 11년 전 | 1585 | ||
| 7294 | 11년 전 | 943 | ||
| 7293 | 11년 전 | 835 | ||
| 7292 | 11년 전 | 924 | ||
| 7291 |
잘살아보자
|
11년 전 | 1110 | |
| 7290 |
잘살아보자
|
11년 전 | 793 | |
| 7289 | 11년 전 | 828 | ||
| 7288 |
잘살아보자
|
11년 전 | 1368 | |
| 7287 | 11년 전 | 852 | ||
| 7286 |
잘살아보자
|
11년 전 | 1355 | |
| 7285 | 11년 전 | 849 | ||
| 7284 | 11년 전 | 999 | ||
| 7283 | 11년 전 | 1024 | ||
| 7282 | 11년 전 | 789 | ||
| 7281 | 11년 전 | 829 | ||
| 7280 | 11년 전 | 1078 | ||
| 7279 | 11년 전 | 2002 | ||
| 7278 | 11년 전 | 834 | ||
| 7277 | 11년 전 | 843 | ||
| 7276 | 11년 전 | 776 | ||
| 7275 | 11년 전 | 1199 | ||
| 7274 | 11년 전 | 841 | ||
| 7273 | 11년 전 | 768 | ||
| 7272 | 11년 전 | 1089 | ||
| 7271 | 11년 전 | 1421 | ||
| 7270 | 11년 전 | 1042 | ||
| 7269 | 11년 전 | 981 | ||
| 7268 | 11년 전 | 1013 | ||
| 7267 | 11년 전 | 1864 | ||
| 7266 | 11년 전 | 924 | ||
| 7265 | 11년 전 | 973 | ||
| 7264 |
잘살아보자
|
11년 전 | 2735 | |
| 7263 |
잘살아보자
|
11년 전 | 2273 | |
| 7262 |
잘살아보자
|
11년 전 | 1148 | |
| 7261 |
잘살아보자
|
11년 전 | 1644 | |
| 7260 |
잘살아보자
|
11년 전 | 1265 | |
| 7259 | 11년 전 | 1180 | ||
| 7258 |
잘살아보자
|
11년 전 | 1312 | |
| 7257 |
잘살아보자
|
11년 전 | 1912 | |
| 7256 | 11년 전 | 959 | ||
| 7255 |
그누5입문
|
11년 전 | 1968 | |
| 7254 | 11년 전 | 2179 | ||
| 7253 |
|
11년 전 | 881 | |
| 7252 | 11년 전 | 1015 | ||
| 7251 | 11년 전 | 733 | ||
| 7250 | 11년 전 | 1703 | ||
| 7249 | 11년 전 | 1559 | ||
| 7248 |
sogo87
|
11년 전 | 1056 | |
| 7247 | 11년 전 | 956 | ||
| 7246 | 11년 전 | 723 | ||
| 7245 |
잘살아보자
|
11년 전 | 1093 | |
| 7244 | 11년 전 | 1545 | ||
| 7243 |
presee
|
11년 전 | 613 | |
| 7242 |
sogo87
|
11년 전 | 801 | |
| 7241 | 11년 전 | 925 | ||
| 7240 |
브라이언2
|
11년 전 | 933 | |
| 7239 |
|
11년 전 | 1148 | |
| 7238 | 11년 전 | 2643 | ||
| 7237 |
잘살아보자
|
11년 전 | 2281 | |
| 7236 |
dethos79
|
11년 전 | 1856 | |
| 7235 |
멋진남자임
|
11년 전 | 1420 | |
| 7234 | 11년 전 | 1359 | ||
| 7233 | 11년 전 | 2340 | ||
| 7232 | 11년 전 | 1619 | ||
| 7231 | 11년 전 | 2803 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기