클라이언트 측에서 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
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 4730 |
제너레이션
|
13년 전 | 1002 | |
| 4729 | 13년 전 | 945 | ||
| 4728 | 13년 전 | 701 | ||
| 4727 | 13년 전 | 1245 | ||
| 4726 | 13년 전 | 850 | ||
| 4725 | 13년 전 | 1681 | ||
| 4724 | 13년 전 | 1020 | ||
| 4723 | 13년 전 | 2689 | ||
| 4722 | 13년 전 | 560 | ||
| 4721 |
ECEditor
|
13년 전 | 2233 | |
| 4720 | 13년 전 | 2615 | ||
| 4719 | 13년 전 | 4384 | ||
| 4718 | 13년 전 | 962 | ||
| 4717 | 13년 전 | 1174 | ||
| 4716 | 13년 전 | 1353 | ||
| 4715 |
한번잘해보자
|
13년 전 | 1169 | |
| 4714 | 13년 전 | 1177 | ||
| 4713 | 13년 전 | 2827 | ||
| 4712 | 13년 전 | 1250 | ||
| 4711 |
김준수사랑
|
13년 전 | 1014 | |
| 4710 |
한번잘해보자
|
13년 전 | 1146 | |
| 4709 | 13년 전 | 1142 | ||
| 4708 | 13년 전 | 820 | ||
| 4707 | 13년 전 | 1701 | ||
| 4706 |
프로프리랜서
|
13년 전 | 2089 | |
| 4705 |
프로프리랜서
|
13년 전 | 1380 | |
| 4704 | 13년 전 | 968 | ||
| 4703 |
프로프리랜서
|
13년 전 | 936 | |
| 4702 | 13년 전 | 833 | ||
| 4701 | 13년 전 | 1570 | ||
| 4700 | 13년 전 | 2598 | ||
| 4699 | 13년 전 | 1311 | ||
| 4698 |
|
13년 전 | 1599 | |
| 4697 |
|
13년 전 | 1118 | |
| 4696 |
|
13년 전 | 1136 | |
| 4695 |
|
13년 전 | 1347 | |
| 4694 |
|
13년 전 | 864 | |
| 4693 |
|
13년 전 | 855 | |
| 4692 |
|
13년 전 | 858 | |
| 4691 |
|
13년 전 | 1186 | |
| 4690 |
|
13년 전 | 1271 | |
| 4689 |
|
13년 전 | 1019 | |
| 4688 |
|
13년 전 | 780 | |
| 4687 |
|
13년 전 | 1055 | |
| 4686 |
|
13년 전 | 1009 | |
| 4685 |
|
13년 전 | 940 | |
| 4684 |
|
13년 전 | 1042 | |
| 4683 |
|
13년 전 | 932 | |
| 4682 |
|
13년 전 | 1243 | |
| 4681 |
|
13년 전 | 1020 | |
| 4680 |
|
13년 전 | 1141 | |
| 4679 |
|
13년 전 | 1654 | |
| 4678 |
|
13년 전 | 580 | |
| 4677 | 13년 전 | 2913 | ||
| 4676 |
복이219
|
13년 전 | 616 | |
| 4675 | 13년 전 | 816 | ||
| 4674 | 13년 전 | 614 | ||
| 4673 | 13년 전 | 991 | ||
| 4672 | 13년 전 | 934 | ||
| 4671 | 13년 전 | 1198 | ||
| 4670 | 13년 전 | 718 | ||
| 4669 | 13년 전 | 1778 | ||
| 4668 | 13년 전 | 1420 | ||
| 4667 |
너는나의봄이다
|
13년 전 | 1021 | |
| 4666 | 13년 전 | 6695 | ||
| 4665 | 13년 전 | 626 | ||
| 4664 | 13년 전 | 1001 | ||
| 4663 | 13년 전 | 843 | ||
| 4662 | 13년 전 | 975 | ||
| 4661 | 13년 전 | 1244 | ||
| 4660 | 13년 전 | 842 | ||
| 4659 | 13년 전 | 1103 | ||
| 4658 |
소나무닷컴
|
13년 전 | 688 | |
| 4657 | 13년 전 | 709 | ||
| 4656 |
|
13년 전 | 1242 | |
| 4655 | 13년 전 | 3101 | ||
| 4654 | 13년 전 | 677 | ||
| 4653 | 13년 전 | 2098 | ||
| 4652 | 13년 전 | 873 | ||
| 4651 | 13년 전 | 776 | ||
| 4650 | 13년 전 | 1664 | ||
| 4649 | 13년 전 | 1600 | ||
| 4648 | 13년 전 | 611 | ||
| 4647 | 13년 전 | 1506 | ||
| 4646 | 13년 전 | 1937 | ||
| 4645 | 13년 전 | 1334 | ||
| 4644 | 13년 전 | 610 | ||
| 4643 | 13년 전 | 2023 | ||
| 4642 | 13년 전 | 817 | ||
| 4641 |
|
13년 전 | 606 | |
| 4640 | 13년 전 | 566 | ||
| 4639 |
|
13년 전 | 1295 | |
| 4638 |
|
13년 전 | 1665 | |
| 4637 |
|
13년 전 | 1137 | |
| 4636 | 13년 전 | 631 | ||
| 4635 | 13년 전 | 759 | ||
| 4634 | 13년 전 | 1263 | ||
| 4633 | 13년 전 | 1245 | ||
| 4632 |
|
13년 전 | 541 | |
| 4631 | 13년 전 | 3342 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기