클라이언트 측에서 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
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 4630 | 13년 전 | 1194 | ||
| 4629 | 13년 전 | 4365 | ||
| 4628 | 13년 전 | 778 | ||
| 4627 |
|
13년 전 | 1767 | |
| 4626 | 13년 전 | 819 | ||
| 4625 |
마릴릴모니
|
13년 전 | 740 | |
| 4624 | 13년 전 | 1644 | ||
| 4623 |
SIR정회원
|
13년 전 | 621 | |
| 4622 |
rakoos
|
13년 전 | 1580 | |
| 4621 | 13년 전 | 689 | ||
| 4620 | 13년 전 | 1477 | ||
| 4619 | 13년 전 | 1003 | ||
| 4618 | 13년 전 | 4052 | ||
| 4617 | 13년 전 | 2047 | ||
| 4616 | 13년 전 | 870 | ||
| 4615 | 13년 전 | 690 | ||
| 4614 | 13년 전 | 1259 | ||
| 4613 | 13년 전 | 896 | ||
| 4612 |
rakoos
|
13년 전 | 1024 | |
| 4611 |
|
13년 전 | 2121 | |
| 4610 | 13년 전 | 775 | ||
| 4609 | 13년 전 | 2826 | ||
| 4608 | 13년 전 | 2815 | ||
| 4607 | 13년 전 | 1082 | ||
| 4606 | 13년 전 | 779 | ||
| 4605 | 13년 전 | 2321 | ||
| 4604 | 13년 전 | 895 | ||
| 4603 | 13년 전 | 1146 | ||
| 4602 |
한번잘해보자
|
13년 전 | 691 | |
| 4601 | 13년 전 | 1808 | ||
| 4600 |
|
13년 전 | 1092 | |
| 4599 |
크라운엠버서더
|
13년 전 | 1155 | |
| 4598 | 13년 전 | 1508 | ||
| 4597 | 13년 전 | 609 | ||
| 4596 | 13년 전 | 3696 | ||
| 4595 |
|
13년 전 | 925 | |
| 4594 | 13년 전 | 1803 | ||
| 4593 | 13년 전 | 1292 | ||
| 4592 | 13년 전 | 665 | ||
| 4591 | 13년 전 | 4654 | ||
| 4590 | 13년 전 | 527 | ||
| 4589 | 13년 전 | 2646 | ||
| 4588 |
|
13년 전 | 996 | |
| 4587 | 13년 전 | 663 | ||
| 4586 |
JavaDD
|
13년 전 | 1022 | |
| 4585 | 13년 전 | 7795 | ||
| 4584 | 13년 전 | 993 | ||
| 4583 |
PHPㅡASP프로그래머
|
13년 전 | 2072 | |
| 4582 |
PHPㅡASP프로그래머
|
13년 전 | 1508 | |
| 4581 |
PHPㅡASP프로그래머
|
13년 전 | 1029 | |
| 4580 | 13년 전 | 4102 | ||
| 4579 |
|
13년 전 | 696 | |
| 4578 | 13년 전 | 1196 | ||
| 4577 | 13년 전 | 823 | ||
| 4576 |
Kanzi
|
13년 전 | 882 | |
| 4575 |
|
13년 전 | 1565 | |
| 4574 | 13년 전 | 2356 | ||
| 4573 |
달빛소나타
|
13년 전 | 886 | |
| 4572 | 13년 전 | 1005 | ||
| 4571 | 13년 전 | 951 | ||
| 4570 |
|
13년 전 | 1323 | |
| 4569 |
한번잘해보자
|
13년 전 | 567 | |
| 4568 |
Raizond
|
13년 전 | 1036 | |
| 4567 |
Raizond
|
13년 전 | 544 | |
| 4566 |
Revenge
|
13년 전 | 957 | |
| 4565 |
|
13년 전 | 713 | |
| 4564 |
|
13년 전 | 1148 | |
| 4563 | 13년 전 | 1580 | ||
| 4562 | 13년 전 | 1229 | ||
| 4561 | 13년 전 | 9411 | ||
| 4560 | 13년 전 | 1814 | ||
| 4559 | 13년 전 | 3371 | ||
| 4558 | 13년 전 | 485 | ||
| 4557 | 13년 전 | 1457 | ||
| 4556 | 13년 전 | 719 | ||
| 4555 | 13년 전 | 560 | ||
| 4554 | 13년 전 | 552 | ||
| 4553 |
|
13년 전 | 4317 | |
| 4552 | 13년 전 | 1516 | ||
| 4551 | 13년 전 | 1999 | ||
| 4550 | 13년 전 | 689 | ||
| 4549 | 13년 전 | 1046 | ||
| 4548 | 13년 전 | 1581 | ||
| 4547 | 13년 전 | 569 | ||
| 4546 | 13년 전 | 1624 | ||
| 4545 | 13년 전 | 1344 | ||
| 4544 | 13년 전 | 3041 | ||
| 4543 | 13년 전 | 1023 | ||
| 4542 | 13년 전 | 2273 | ||
| 4541 | 13년 전 | 1143 | ||
| 4540 |
|
13년 전 | 1070 | |
| 4539 | 13년 전 | 1171 | ||
| 4538 | 13년 전 | 1597 | ||
| 4537 | 13년 전 | 1181 | ||
| 4536 | 13년 전 | 566 | ||
| 4535 |
|
13년 전 | 837 | |
| 4534 |
|
13년 전 | 987 | |
| 4533 | 13년 전 | 659 | ||
| 4532 |
soing
|
13년 전 | 7384 | |
| 4531 |
|
13년 전 | 6409 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기