클라이언트 측에서 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
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7530 | 10년 전 | 780 | ||
| 7529 |
파랑새1597
|
10년 전 | 1198 | |
| 7528 |
파랑새1597
|
10년 전 | 1302 | |
| 7527 |
integrity7
|
10년 전 | 1380 | |
| 7526 | 10년 전 | 2401 | ||
| 7525 |
다빈치코드777
|
10년 전 | 1093 | |
| 7524 | 10년 전 | 1557 | ||
| 7523 | 10년 전 | 953 | ||
| 7522 |
|
10년 전 | 985 | |
| 7521 |
blackkil
|
10년 전 | 1858 | |
| 7520 | 10년 전 | 1278 | ||
| 7519 |
Gaumi
|
10년 전 | 1073 | |
| 7518 | 10년 전 | 1474 | ||
| 7517 | 10년 전 | 814 | ||
| 7516 | 10년 전 | 1278 | ||
| 7515 | 10년 전 | 1392 | ||
| 7514 |
|
10년 전 | 4483 | |
| 7513 |
멋진남자임
|
10년 전 | 1133 | |
| 7512 |
다빈치코드777
|
10년 전 | 864 | |
| 7511 |
|
10년 전 | 3385 | |
| 7510 | 10년 전 | 1358 | ||
| 7509 | 10년 전 | 1134 | ||
| 7508 | 10년 전 | 711 | ||
| 7507 |
senseme
|
10년 전 | 734 | |
| 7506 |
멋진남자임
|
10년 전 | 1626 | |
| 7505 | 10년 전 | 3987 | ||
| 7504 | 10년 전 | 2138 | ||
| 7503 | 10년 전 | 988 | ||
| 7502 | 10년 전 | 514 | ||
| 7501 | 10년 전 | 1435 | ||
| 7500 | 10년 전 | 1482 | ||
| 7499 | 10년 전 | 3371 | ||
| 7498 | 10년 전 | 1194 | ||
| 7497 |
dethos79
|
10년 전 | 2956 | |
| 7496 | 10년 전 | 2138 | ||
| 7495 | 10년 전 | 848 | ||
| 7494 |
CHAVO
|
10년 전 | 1120 | |
| 7493 | 10년 전 | 2642 | ||
| 7492 | 10년 전 | 1253 | ||
| 7491 | 10년 전 | 1458 | ||
| 7490 | 10년 전 | 2324 | ||
| 7489 | 10년 전 | 2117 | ||
| 7488 |
toptopon
|
10년 전 | 887 | |
| 7487 |
|
10년 전 | 1025 | |
| 7486 | 10년 전 | 3342 | ||
| 7485 | 10년 전 | 1306 | ||
| 7484 | 10년 전 | 1364 | ||
| 7483 | 10년 전 | 1018 | ||
| 7482 | 10년 전 | 646 | ||
| 7481 | 10년 전 | 854 | ||
| 7480 | 10년 전 | 1217 | ||
| 7479 | 10년 전 | 2596 | ||
| 7478 | 10년 전 | 1154 | ||
| 7477 |
멋진남자임
|
10년 전 | 1505 | |
| 7476 |
zeppeto
|
10년 전 | 1137 | |
| 7475 |
200점아빠
|
10년 전 | 908 | |
| 7474 | 10년 전 | 3999 | ||
| 7473 | 10년 전 | 983 | ||
| 7472 |
나르시스1
|
10년 전 | 1233 | |
| 7471 | 10년 전 | 869 | ||
| 7470 | 10년 전 | 1268 | ||
| 7469 |
플라이SINJI
|
10년 전 | 959 | |
| 7468 |
|
10년 전 | 537 | |
| 7467 |
|
10년 전 | 645 | |
| 7466 | 10년 전 | 1107 | ||
| 7465 | 10년 전 | 1176 | ||
| 7464 |
|
10년 전 | 1180 | |
| 7463 | 10년 전 | 1234 | ||
| 7462 |
진짜별사탕
|
10년 전 | 849 | |
| 7461 | 10년 전 | 936 | ||
| 7460 | 10년 전 | 3718 | ||
| 7459 |
멋진남자임
|
10년 전 | 1546 | |
| 7458 |
멋진남자임
|
10년 전 | 477 | |
| 7457 | 10년 전 | 912 | ||
| 7456 | 10년 전 | 753 | ||
| 7455 | 10년 전 | 2142 | ||
| 7454 | 10년 전 | 626 | ||
| 7453 | 10년 전 | 818 | ||
| 7452 |
중국어사이트제작
|
10년 전 | 502 | |
| 7451 | 10년 전 | 900 | ||
| 7450 | 10년 전 | 624 | ||
| 7449 |
울라라라우
|
10년 전 | 942 | |
| 7448 | 10년 전 | 1625 | ||
| 7447 |
멋진남자임
|
10년 전 | 493 | |
| 7446 | 10년 전 | 542 | ||
| 7445 |
네이비칼라
|
10년 전 | 1664 | |
| 7444 |
senseme
|
10년 전 | 1397 | |
| 7443 | 10년 전 | 1331 | ||
| 7442 | 10년 전 | 722 | ||
| 7441 |
멋진남자임
|
10년 전 | 1426 | |
| 7440 | 10년 전 | 887 | ||
| 7439 |
|
10년 전 | 745 | |
| 7438 |
|
10년 전 | 924 | |
| 7437 |
basement
|
10년 전 | 1026 | |
| 7436 |
잘살아보자
|
10년 전 | 1118 | |
| 7435 | 10년 전 | 1076 | ||
| 7434 | 10년 전 | 3788 | ||
| 7433 |
|
10년 전 | 2727 | |
| 7432 |
alexkim
|
10년 전 | 856 | |
| 7431 |
이웃집초보
|
11년 전 | 1300 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기