클라이언트 측에서 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
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7630 | 10년 전 | 667 | ||
| 7629 |
|
10년 전 | 2409 | |
| 7628 | 10년 전 | 800 | ||
| 7627 |
|
10년 전 | 1042 | |
| 7626 |
|
10년 전 | 1799 | |
| 7625 | 10년 전 | 723 | ||
| 7624 | 10년 전 | 742 | ||
| 7623 |
|
10년 전 | 3115 | |
| 7622 | 10년 전 | 745 | ||
| 7621 |
leeleeleelee
|
10년 전 | 594 | |
| 7620 | 10년 전 | 548 | ||
| 7619 | 10년 전 | 501 | ||
| 7618 | 10년 전 | 1040 | ||
| 7617 | 10년 전 | 733 | ||
| 7616 | 10년 전 | 666 | ||
| 7615 | 10년 전 | 734 | ||
| 7614 | 10년 전 | 1277 | ||
| 7613 |
|
10년 전 | 2090 | |
| 7612 | 10년 전 | 1169 | ||
| 7611 | 10년 전 | 1431 | ||
| 7610 |
|
10년 전 | 1909 | |
| 7609 |
|
10년 전 | 1363 | |
| 7608 |
mwdkim
|
10년 전 | 1143 | |
| 7607 |
|
10년 전 | 1071 | |
| 7606 |
mwdkim
|
10년 전 | 3948 | |
| 7605 | 10년 전 | 698 | ||
| 7604 | 10년 전 | 1037 | ||
| 7603 | 10년 전 | 1658 | ||
| 7602 |
|
10년 전 | 1088 | |
| 7601 |
AniNest
|
10년 전 | 2804 | |
| 7600 |
port443
|
10년 전 | 1046 | |
| 7599 | 10년 전 | 954 | ||
| 7598 | 10년 전 | 1035 | ||
| 7597 | 10년 전 | 4583 | ||
| 7596 |
SeungYeon
|
10년 전 | 905 | |
| 7595 |
untitled
|
10년 전 | 2445 | |
| 7594 |
프로그래머7
|
10년 전 | 1745 | |
| 7593 |
untitled
|
10년 전 | 2387 | |
| 7592 |
untitled
|
10년 전 | 1955 | |
| 7591 |
untitled
|
10년 전 | 2688 | |
| 7590 |
아리마2001
|
10년 전 | 862 | |
| 7589 | 10년 전 | 1118 | ||
| 7588 |
|
10년 전 | 2932 | |
| 7587 | 10년 전 | 1317 | ||
| 7586 | 10년 전 | 679 | ||
| 7585 | 10년 전 | 1712 | ||
| 7584 | 10년 전 | 1419 | ||
| 7583 |
leeleeleelee
|
10년 전 | 1179 | |
| 7582 |
|
10년 전 | 1140 | |
| 7581 | 10년 전 | 1367 | ||
| 7580 | 10년 전 | 1018 | ||
| 7579 |
|
10년 전 | 614 | |
| 7578 | 10년 전 | 1439 | ||
| 7577 |
|
10년 전 | 1882 | |
| 7576 | 10년 전 | 1396 | ||
| 7575 |
멋진남자임
|
10년 전 | 1478 | |
| 7574 | 10년 전 | 2131 | ||
| 7573 | 10년 전 | 3267 | ||
| 7572 | 10년 전 | 770 | ||
| 7571 |
|
10년 전 | 791 | |
| 7570 |
|
10년 전 | 1331 | |
| 7569 | 10년 전 | 1561 | ||
| 7568 |
this1mg
|
10년 전 | 1059 | |
| 7567 |
|
10년 전 | 775 | |
| 7566 | 10년 전 | 926 | ||
| 7565 |
Angel하늘
|
10년 전 | 1025 | |
| 7564 |
seoldi
|
10년 전 | 1268 | |
| 7563 |
|
10년 전 | 1406 | |
| 7562 |
멋진남자임
|
10년 전 | 2103 | |
| 7561 | 10년 전 | 722 | ||
| 7560 |
leeleeleelee
|
10년 전 | 922 | |
| 7559 | 10년 전 | 5064 | ||
| 7558 |
RinaP
|
10년 전 | 799 | |
| 7557 |
|
10년 전 | 1265 | |
| 7556 | 10년 전 | 1205 | ||
| 7555 |
hyohyojj1234
|
10년 전 | 1676 | |
| 7554 | 10년 전 | 1104 | ||
| 7553 |
senseme
|
10년 전 | 1348 | |
| 7552 |
ehdltdoit
|
10년 전 | 1446 | |
| 7551 |
|
10년 전 | 1838 | |
| 7550 |
leeleeleelee
|
10년 전 | 1605 | |
| 7549 | 10년 전 | 2442 | ||
| 7548 | 10년 전 | 1854 | ||
| 7547 |
멋진남자임
|
10년 전 | 1973 | |
| 7546 | 10년 전 | 1017 | ||
| 7545 |
ILMare1003
|
10년 전 | 1303 | |
| 7544 |
|
10년 전 | 1262 | |
| 7543 | 10년 전 | 898 | ||
| 7542 | 10년 전 | 676 | ||
| 7541 |
울라라라우
|
10년 전 | 874 | |
| 7540 | 10년 전 | 1604 | ||
| 7539 | 10년 전 | 949 | ||
| 7538 |
|
10년 전 | 1839 | |
| 7537 | 10년 전 | 3623 | ||
| 7536 |
Gaumi
|
10년 전 | 1426 | |
| 7535 |
프로그램은어려워
|
10년 전 | 1288 | |
| 7534 |
senseme
|
10년 전 | 1213 | |
| 7533 | 10년 전 | 1214 | ||
| 7532 | 10년 전 | 879 | ||
| 7531 | 10년 전 | 2068 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기