클라이언트 측에서 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
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 4030 | 14년 전 | 2109 | ||
| 4029 |
|
14년 전 | 704 | |
| 4028 | 14년 전 | 3617 | ||
| 4027 | 14년 전 | 3746 | ||
| 4026 |
techer
|
14년 전 | 1120 | |
| 4025 |
techer
|
14년 전 | 685 | |
| 4024 | 14년 전 | 1357 | ||
| 4023 | 14년 전 | 601 | ||
| 4022 | 14년 전 | 921 | ||
| 4021 | 14년 전 | 512 | ||
| 4020 | 14년 전 | 7335 | ||
| 4019 | 14년 전 | 1023 | ||
| 4018 | 14년 전 | 440 | ||
| 4017 | 14년 전 | 598 | ||
| 4016 | 14년 전 | 1303 | ||
| 4015 | 14년 전 | 734 | ||
| 4014 | 14년 전 | 563 | ||
| 4013 | 14년 전 | 686 | ||
| 4012 | 14년 전 | 616 | ||
| 4011 |
브라운벤취
|
14년 전 | 424 | |
| 4010 |
크라잉감튀
|
14년 전 | 592 | |
| 4009 | 14년 전 | 572 | ||
| 4008 | 14년 전 | 562 | ||
| 4007 | 14년 전 | 634 | ||
| 4006 |
네비플러스
|
14년 전 | 879 | |
| 4005 | 14년 전 | 892 | ||
| 4004 | 14년 전 | 1116 | ||
| 4003 | 14년 전 | 777 | ||
| 4002 |
핑크스파이더
|
14년 전 | 696 | |
| 4001 | 14년 전 | 577 | ||
| 4000 |
BYongLuv
|
14년 전 | 544 | |
| 3999 |
xxbobo
|
14년 전 | 529 | |
| 3998 | 14년 전 | 714 | ||
| 3997 | 14년 전 | 1929 | ||
| 3996 | 14년 전 | 580 | ||
| 3995 | 14년 전 | 908 | ||
| 3994 |
asdfdasfddd
|
14년 전 | 2077 | |
| 3993 | 14년 전 | 1177 | ||
| 3992 | 14년 전 | 952 | ||
| 3991 | 14년 전 | 4689 | ||
| 3990 |
Torrious
|
14년 전 | 1895 | |
| 3989 | 14년 전 | 759 | ||
| 3988 |
내꿈은대통령
|
14년 전 | 626 | |
| 3987 | 14년 전 | 617 | ||
| 3986 |
|
14년 전 | 468 | |
| 3985 | 14년 전 | 1737 | ||
| 3984 | 14년 전 | 3057 | ||
| 3983 | 14년 전 | 551 | ||
| 3982 | 14년 전 | 748 | ||
| 3981 | 14년 전 | 1733 | ||
| 3980 | 14년 전 | 596 | ||
| 3979 |
AMDbest
|
14년 전 | 1249 | |
| 3978 |
leadK
|
14년 전 | 1599 | |
| 3977 |
좋은천사7
|
14년 전 | 10382 | |
| 3976 |
좋은천사7
|
14년 전 | 1127 | |
| 3975 |
좋은천사7
|
14년 전 | 940 | |
| 3974 |
좋은천사7
|
14년 전 | 1657 | |
| 3973 |
좋은천사7
|
14년 전 | 1694 | |
| 3972 |
좋은천사7
|
14년 전 | 867 | |
| 3971 |
김준수사랑
|
14년 전 | 968 | |
| 3970 |
레인보우1492
|
14년 전 | 785 | |
| 3969 | 14년 전 | 2418 | ||
| 3968 | 14년 전 | 578 | ||
| 3967 | 14년 전 | 723 | ||
| 3966 | 14년 전 | 1783 | ||
| 3965 | 14년 전 | 2066 | ||
| 3964 |
방황하는중년
|
14년 전 | 514 | |
| 3963 |
네비플러스
|
14년 전 | 892 | |
| 3962 | 14년 전 | 676 | ||
| 3961 | 14년 전 | 731 | ||
| 3960 | 14년 전 | 925 | ||
| 3959 | 14년 전 | 737 | ||
| 3958 |
techer
|
14년 전 | 648 | |
| 3957 |
techer
|
14년 전 | 463 | |
| 3956 |
techer
|
14년 전 | 440 | |
| 3955 |
techer
|
14년 전 | 669 | |
| 3954 |
8제임스8
|
14년 전 | 822 | |
| 3953 |
구름1354
|
14년 전 | 638 | |
| 3952 |
8제임스8
|
14년 전 | 615 | |
| 3951 | 14년 전 | 2434 | ||
| 3950 | 14년 전 | 949 | ||
| 3949 | 14년 전 | 1098 | ||
| 3948 | 14년 전 | 1076 | ||
| 3947 | 14년 전 | 1509 | ||
| 3946 |
|
14년 전 | 1898 | |
| 3945 | 14년 전 | 594 | ||
| 3944 |
|
14년 전 | 772 | |
| 3943 | 14년 전 | 1810 | ||
| 3942 | 14년 전 | 798 | ||
| 3941 | 14년 전 | 2098 | ||
| 3940 |
내일은없다
|
14년 전 | 583 | |
| 3939 | 14년 전 | 782 | ||
| 3938 | 14년 전 | 893 | ||
| 3937 | 14년 전 | 2010 | ||
| 3936 | 14년 전 | 832 | ||
| 3935 | 14년 전 | 3198 | ||
| 3934 | 14년 전 | 963 | ||
| 3933 | 14년 전 | 493 | ||
| 3932 | 14년 전 | 823 | ||
| 3931 |
Jos87
|
14년 전 | 672 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기