클라이언트 측에서 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
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8030 | 9년 전 | 368 | ||
| 8029 | 9년 전 | 308 | ||
| 8028 | 9년 전 | 262 | ||
| 8027 | 9년 전 | 279 | ||
| 8026 | 9년 전 | 336 | ||
| 8025 | 9년 전 | 383 | ||
| 8024 | 9년 전 | 343 | ||
| 8023 | 9년 전 | 392 | ||
| 8022 | 9년 전 | 322 | ||
| 8021 | 9년 전 | 327 | ||
| 8020 | 9년 전 | 320 | ||
| 8019 | 9년 전 | 344 | ||
| 8018 | 9년 전 | 447 | ||
| 8017 | 9년 전 | 539 | ||
| 8016 | 9년 전 | 327 | ||
| 8015 | 9년 전 | 388 | ||
| 8014 | 9년 전 | 326 | ||
| 8013 | 9년 전 | 232 | ||
| 8012 | 9년 전 | 243 | ||
| 8011 | 9년 전 | 446 | ||
| 8010 | 9년 전 | 300 | ||
| 8009 | 9년 전 | 288 | ||
| 8008 | 9년 전 | 286 | ||
| 8007 | 9년 전 | 429 | ||
| 8006 | 9년 전 | 461 | ||
| 8005 |
|
9년 전 | 966 | |
| 8004 | 9년 전 | 358 | ||
| 8003 | 9년 전 | 423 | ||
| 8002 | 9년 전 | 321 | ||
| 8001 |
|
9년 전 | 665 | |
| 8000 | 9년 전 | 417 | ||
| 7999 | 9년 전 | 375 | ||
| 7998 | 9년 전 | 427 | ||
| 7997 | 9년 전 | 311 | ||
| 7996 | 9년 전 | 534 | ||
| 7995 | 9년 전 | 455 | ||
| 7994 | 9년 전 | 334 | ||
| 7993 | 9년 전 | 394 | ||
| 7992 | 9년 전 | 508 | ||
| 7991 | 9년 전 | 250 | ||
| 7990 | 9년 전 | 287 | ||
| 7989 | 9년 전 | 303 | ||
| 7988 | 9년 전 | 725 | ||
| 7987 | 9년 전 | 425 | ||
| 7986 | 9년 전 | 418 | ||
| 7985 | 9년 전 | 510 | ||
| 7984 | 9년 전 | 430 | ||
| 7983 | 9년 전 | 662 | ||
| 7982 | 9년 전 | 518 | ||
| 7981 | 9년 전 | 470 | ||
| 7980 | 9년 전 | 490 | ||
| 7979 | 9년 전 | 472 | ||
| 7978 | 9년 전 | 454 | ||
| 7977 | 9년 전 | 390 | ||
| 7976 | 9년 전 | 849 | ||
| 7975 | 9년 전 | 360 | ||
| 7974 | 9년 전 | 397 | ||
| 7973 | 9년 전 | 596 | ||
| 7972 | 9년 전 | 383 | ||
| 7971 | 9년 전 | 458 | ||
| 7970 | 9년 전 | 299 | ||
| 7969 | 9년 전 | 542 | ||
| 7968 | 9년 전 | 384 | ||
| 7967 | 9년 전 | 370 | ||
| 7966 | 9년 전 | 371 | ||
| 7965 |
|
9년 전 | 1018 | |
| 7964 | 9년 전 | 398 | ||
| 7963 | 9년 전 | 397 | ||
| 7962 | 9년 전 | 374 | ||
| 7961 |
전갈자리남자
|
9년 전 | 505 | |
| 7960 | 9년 전 | 964 | ||
| 7959 | 9년 전 | 554 | ||
| 7958 | 9년 전 | 408 | ||
| 7957 | 9년 전 | 366 | ||
| 7956 | 9년 전 | 367 | ||
| 7955 | 9년 전 | 457 | ||
| 7954 | 9년 전 | 377 | ||
| 7953 | 9년 전 | 428 | ||
| 7952 | 9년 전 | 355 | ||
| 7951 | 9년 전 | 503 | ||
| 7950 | 9년 전 | 390 | ||
| 7949 | 9년 전 | 385 | ||
| 7948 | 9년 전 | 323 | ||
| 7947 | 9년 전 | 934 | ||
| 7946 | 9년 전 | 433 | ||
| 7945 | 9년 전 | 397 | ||
| 7944 | 9년 전 | 424 | ||
| 7943 | 9년 전 | 376 | ||
| 7942 | 9년 전 | 405 | ||
| 7941 | 9년 전 | 392 | ||
| 7940 | 9년 전 | 882 | ||
| 7939 | 9년 전 | 354 | ||
| 7938 | 9년 전 | 387 | ||
| 7937 | 9년 전 | 276 | ||
| 7936 | 9년 전 | 884 | ||
| 7935 | 9년 전 | 450 | ||
| 7934 | 9년 전 | 420 | ||
| 7933 | 9년 전 | 512 | ||
| 7932 | 9년 전 | 488 | ||
| 7931 | 9년 전 | 534 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기