클라이언트 측에서 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년 전 | 1189 | ||
| 4629 | 13년 전 | 4362 | ||
| 4628 | 13년 전 | 766 | ||
| 4627 |
|
13년 전 | 1759 | |
| 4626 | 13년 전 | 815 | ||
| 4625 |
마릴릴모니
|
13년 전 | 738 | |
| 4624 | 13년 전 | 1637 | ||
| 4623 |
SIR정회원
|
13년 전 | 619 | |
| 4622 |
rakoos
|
13년 전 | 1577 | |
| 4621 | 13년 전 | 686 | ||
| 4620 | 13년 전 | 1473 | ||
| 4619 | 13년 전 | 1002 | ||
| 4618 | 13년 전 | 4048 | ||
| 4617 | 13년 전 | 2042 | ||
| 4616 | 13년 전 | 861 | ||
| 4615 | 13년 전 | 684 | ||
| 4614 | 13년 전 | 1251 | ||
| 4613 | 13년 전 | 895 | ||
| 4612 |
rakoos
|
13년 전 | 1022 | |
| 4611 |
|
13년 전 | 2116 | |
| 4610 | 13년 전 | 771 | ||
| 4609 | 13년 전 | 2823 | ||
| 4608 | 13년 전 | 2813 | ||
| 4607 | 13년 전 | 1077 | ||
| 4606 | 13년 전 | 775 | ||
| 4605 | 13년 전 | 2317 | ||
| 4604 | 13년 전 | 892 | ||
| 4603 | 13년 전 | 1141 | ||
| 4602 |
한번잘해보자
|
13년 전 | 684 | |
| 4601 | 13년 전 | 1807 | ||
| 4600 |
|
13년 전 | 1089 | |
| 4599 |
크라운엠버서더
|
13년 전 | 1154 | |
| 4598 | 13년 전 | 1505 | ||
| 4597 | 13년 전 | 601 | ||
| 4596 | 13년 전 | 3692 | ||
| 4595 |
|
13년 전 | 920 | |
| 4594 | 13년 전 | 1796 | ||
| 4593 | 13년 전 | 1285 | ||
| 4592 | 13년 전 | 664 | ||
| 4591 | 13년 전 | 4647 | ||
| 4590 | 13년 전 | 522 | ||
| 4589 | 13년 전 | 2639 | ||
| 4588 |
|
13년 전 | 996 | |
| 4587 | 13년 전 | 659 | ||
| 4586 |
JavaDD
|
13년 전 | 1017 | |
| 4585 | 13년 전 | 7795 | ||
| 4584 | 13년 전 | 985 | ||
| 4583 |
PHPㅡASP프로그래머
|
13년 전 | 2066 | |
| 4582 |
PHPㅡASP프로그래머
|
13년 전 | 1502 | |
| 4581 |
PHPㅡASP프로그래머
|
13년 전 | 1025 | |
| 4580 | 13년 전 | 4097 | ||
| 4579 |
|
13년 전 | 693 | |
| 4578 | 13년 전 | 1192 | ||
| 4577 | 13년 전 | 822 | ||
| 4576 |
Kanzi
|
13년 전 | 881 | |
| 4575 |
|
13년 전 | 1562 | |
| 4574 | 13년 전 | 2353 | ||
| 4573 |
달빛소나타
|
13년 전 | 883 | |
| 4572 | 13년 전 | 1001 | ||
| 4571 | 13년 전 | 942 | ||
| 4570 |
|
13년 전 | 1313 | |
| 4569 |
한번잘해보자
|
13년 전 | 563 | |
| 4568 |
Raizond
|
13년 전 | 1033 | |
| 4567 |
Raizond
|
13년 전 | 538 | |
| 4566 |
Revenge
|
13년 전 | 954 | |
| 4565 |
|
13년 전 | 711 | |
| 4564 |
|
13년 전 | 1143 | |
| 4563 | 13년 전 | 1576 | ||
| 4562 | 13년 전 | 1226 | ||
| 4561 | 13년 전 | 9406 | ||
| 4560 | 13년 전 | 1810 | ||
| 4559 | 13년 전 | 3368 | ||
| 4558 | 13년 전 | 483 | ||
| 4557 | 13년 전 | 1455 | ||
| 4556 | 13년 전 | 717 | ||
| 4555 | 13년 전 | 556 | ||
| 4554 | 13년 전 | 550 | ||
| 4553 |
|
13년 전 | 4314 | |
| 4552 | 13년 전 | 1512 | ||
| 4551 | 13년 전 | 1994 | ||
| 4550 | 13년 전 | 685 | ||
| 4549 | 13년 전 | 1040 | ||
| 4548 | 13년 전 | 1578 | ||
| 4547 | 13년 전 | 563 | ||
| 4546 | 13년 전 | 1622 | ||
| 4545 | 13년 전 | 1338 | ||
| 4544 | 13년 전 | 3040 | ||
| 4543 | 13년 전 | 1016 | ||
| 4542 | 13년 전 | 2271 | ||
| 4541 | 13년 전 | 1141 | ||
| 4540 |
|
13년 전 | 1066 | |
| 4539 | 13년 전 | 1165 | ||
| 4538 | 13년 전 | 1595 | ||
| 4537 | 13년 전 | 1178 | ||
| 4536 | 13년 전 | 560 | ||
| 4535 |
|
13년 전 | 827 | |
| 4534 |
|
13년 전 | 982 | |
| 4533 | 13년 전 | 656 | ||
| 4532 |
soing
|
13년 전 | 7377 | |
| 4531 |
|
13년 전 | 6402 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기