클라이언트 측에서 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
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7830 | 9년 전 | 388 | ||
| 7829 |
|
9년 전 | 566 | |
| 7828 | 9년 전 | 497 | ||
| 7827 | 9년 전 | 383 | ||
| 7826 | 9년 전 | 390 | ||
| 7825 | 9년 전 | 441 | ||
| 7824 | 9년 전 | 424 | ||
| 7823 | 9년 전 | 332 | ||
| 7822 | 9년 전 | 327 | ||
| 7821 | 9년 전 | 274 | ||
| 7820 | 9년 전 | 328 | ||
| 7819 |
|
10년 전 | 730 | |
| 7818 | 10년 전 | 358 | ||
| 7817 | 10년 전 | 471 | ||
| 7816 | 10년 전 | 378 | ||
| 7815 | 10년 전 | 576 | ||
| 7814 | 10년 전 | 405 | ||
| 7813 | 10년 전 | 343 | ||
| 7812 | 10년 전 | 353 | ||
| 7811 | 10년 전 | 369 | ||
| 7810 | 10년 전 | 522 | ||
| 7809 | 10년 전 | 446 | ||
| 7808 | 10년 전 | 322 | ||
| 7807 | 10년 전 | 371 | ||
| 7806 |
프로그래머7
|
10년 전 | 1311 | |
| 7805 | 10년 전 | 1239 | ||
| 7804 |
zahir1312
|
10년 전 | 752 | |
| 7803 |
|
10년 전 | 1350 | |
| 7802 | 10년 전 | 419 | ||
| 7801 | 10년 전 | 840 | ||
| 7800 | 10년 전 | 1070 | ||
| 7799 | 10년 전 | 513 | ||
| 7798 | 10년 전 | 473 | ||
| 7797 | 10년 전 | 470 | ||
| 7796 | 10년 전 | 311 | ||
| 7795 | 10년 전 | 465 | ||
| 7794 | 10년 전 | 497 | ||
| 7793 | 10년 전 | 1017 | ||
| 7792 | 10년 전 | 419 | ||
| 7791 | 10년 전 | 509 | ||
| 7790 | 10년 전 | 470 | ||
| 7789 |
fbastore
|
10년 전 | 1410 | |
| 7788 | 10년 전 | 504 | ||
| 7787 | 10년 전 | 364 | ||
| 7786 | 10년 전 | 525 | ||
| 7785 | 10년 전 | 538 | ||
| 7784 | 10년 전 | 606 | ||
| 7783 | 10년 전 | 412 | ||
| 7782 | 10년 전 | 455 | ||
| 7781 | 10년 전 | 868 | ||
| 7780 | 10년 전 | 791 | ||
| 7779 | 10년 전 | 759 | ||
| 7778 | 10년 전 | 325 | ||
| 7777 | 10년 전 | 417 | ||
| 7776 | 10년 전 | 417 | ||
| 7775 | 10년 전 | 362 | ||
| 7774 | 10년 전 | 608 | ||
| 7773 | 10년 전 | 350 | ||
| 7772 | 10년 전 | 684 | ||
| 7771 | 10년 전 | 339 | ||
| 7770 | 10년 전 | 621 | ||
| 7769 | 10년 전 | 339 | ||
| 7768 | 10년 전 | 565 | ||
| 7767 | 10년 전 | 1131 | ||
| 7766 | 10년 전 | 458 | ||
| 7765 | 10년 전 | 487 | ||
| 7764 |
잘살아보자
|
10년 전 | 339 | |
| 7763 |
|
10년 전 | 1411 | |
| 7762 |
Tosea
|
10년 전 | 1028 | |
| 7761 | 10년 전 | 615 | ||
| 7760 |
잘살아보자
|
10년 전 | 632 | |
| 7759 |
잘살아보자
|
10년 전 | 443 | |
| 7758 |
잘살아보자
|
10년 전 | 544 | |
| 7757 | 10년 전 | 1195 | ||
| 7756 |
ITBANK
|
10년 전 | 1233 | |
| 7755 | 10년 전 | 1910 | ||
| 7754 | 10년 전 | 1020 | ||
| 7753 | 10년 전 | 850 | ||
| 7752 | 10년 전 | 1357 | ||
| 7751 |
잘살아보자
|
10년 전 | 485 | |
| 7750 |
잘살아보자
|
10년 전 | 447 | |
| 7749 |
잘살아보자
|
10년 전 | 450 | |
| 7748 |
잘살아보자
|
10년 전 | 439 | |
| 7747 |
잘살아보자
|
10년 전 | 536 | |
| 7746 |
잘살아보자
|
10년 전 | 653 | |
| 7745 |
잘살아보자
|
10년 전 | 892 | |
| 7744 |
잘살아보자
|
10년 전 | 397 | |
| 7743 | 10년 전 | 923 | ||
| 7742 |
starbros
|
10년 전 | 805 | |
| 7741 |
잘살아보자
|
10년 전 | 625 | |
| 7740 |
잘살아보자
|
10년 전 | 493 | |
| 7739 |
잘살아보자
|
10년 전 | 447 | |
| 7738 |
잘살아보자
|
10년 전 | 504 | |
| 7737 |
잘살아보자
|
10년 전 | 463 | |
| 7736 |
잘살아보자
|
10년 전 | 480 | |
| 7735 |
잘살아보자
|
10년 전 | 814 | |
| 7734 |
잘살아보자
|
10년 전 | 409 | |
| 7733 |
잘살아보자
|
10년 전 | 517 | |
| 7732 |
잘살아보자
|
10년 전 | 669 | |
| 7731 |
잘살아보자
|
10년 전 | 589 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기