클라이언트 측에서 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
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7930 | 9년 전 | 371 | ||
| 7929 | 9년 전 | 263 | ||
| 7928 | 9년 전 | 374 | ||
| 7927 | 9년 전 | 297 | ||
| 7926 | 9년 전 | 644 | ||
| 7925 | 9년 전 | 313 | ||
| 7924 | 9년 전 | 286 | ||
| 7923 | 9년 전 | 322 | ||
| 7922 | 9년 전 | 344 | ||
| 7921 | 9년 전 | 374 | ||
| 7920 | 9년 전 | 295 | ||
| 7919 | 9년 전 | 312 | ||
| 7918 | 9년 전 | 475 | ||
| 7917 | 9년 전 | 315 | ||
| 7916 | 9년 전 | 384 | ||
| 7915 | 9년 전 | 369 | ||
| 7914 | 9년 전 | 379 | ||
| 7913 | 9년 전 | 505 | ||
| 7912 | 9년 전 | 379 | ||
| 7911 | 9년 전 | 332 | ||
| 7910 | 9년 전 | 361 | ||
| 7909 | 9년 전 | 471 | ||
| 7908 | 9년 전 | 369 | ||
| 7907 | 9년 전 | 321 | ||
| 7906 | 9년 전 | 336 | ||
| 7905 | 9년 전 | 329 | ||
| 7904 | 9년 전 | 297 | ||
| 7903 | 9년 전 | 294 | ||
| 7902 | 9년 전 | 514 | ||
| 7901 |
|
9년 전 | 716 | |
| 7900 | 9년 전 | 538 | ||
| 7899 | 9년 전 | 346 | ||
| 7898 | 9년 전 | 339 | ||
| 7897 | 9년 전 | 296 | ||
| 7896 | 9년 전 | 316 | ||
| 7895 | 9년 전 | 425 | ||
| 7894 | 9년 전 | 347 | ||
| 7893 | 9년 전 | 279 | ||
| 7892 | 9년 전 | 323 | ||
| 7891 | 9년 전 | 710 | ||
| 7890 | 9년 전 | 1175 | ||
| 7889 | 9년 전 | 730 | ||
| 7888 |
limsy1987
|
9년 전 | 528 | |
| 7887 | 9년 전 | 499 | ||
| 7886 | 9년 전 | 390 | ||
| 7885 | 9년 전 | 361 | ||
| 7884 | 9년 전 | 370 | ||
| 7883 | 9년 전 | 350 | ||
| 7882 | 9년 전 | 363 | ||
| 7881 | 9년 전 | 393 | ||
| 7880 | 9년 전 | 519 | ||
| 7879 | 9년 전 | 413 | ||
| 7878 | 9년 전 | 1157 | ||
| 7877 | 9년 전 | 707 | ||
| 7876 | 9년 전 | 436 | ||
| 7875 | 9년 전 | 510 | ||
| 7874 |
|
9년 전 | 782 | |
| 7873 | 9년 전 | 482 | ||
| 7872 | 9년 전 | 617 | ||
| 7871 | 9년 전 | 446 | ||
| 7870 | 9년 전 | 570 | ||
| 7869 | 9년 전 | 388 | ||
| 7868 | 9년 전 | 384 | ||
| 7867 | 9년 전 | 381 | ||
| 7866 | 9년 전 | 441 | ||
| 7865 | 9년 전 | 399 | ||
| 7864 | 9년 전 | 464 | ||
| 7863 | 9년 전 | 454 | ||
| 7862 | 9년 전 | 432 | ||
| 7861 | 9년 전 | 590 | ||
| 7860 | 9년 전 | 595 | ||
| 7859 | 9년 전 | 364 | ||
| 7858 | 9년 전 | 672 | ||
| 7857 | 9년 전 | 1021 | ||
| 7856 | 9년 전 | 484 | ||
| 7855 | 9년 전 | 699 | ||
| 7854 | 9년 전 | 699 | ||
| 7853 | 9년 전 | 539 | ||
| 7852 | 9년 전 | 473 | ||
| 7851 | 9년 전 | 447 | ||
| 7850 | 9년 전 | 542 | ||
| 7849 | 9년 전 | 316 | ||
| 7848 | 9년 전 | 367 | ||
| 7847 | 9년 전 | 589 | ||
| 7846 | 9년 전 | 405 | ||
| 7845 | 9년 전 | 368 | ||
| 7844 | 9년 전 | 367 | ||
| 7843 | 9년 전 | 373 | ||
| 7842 | 9년 전 | 368 | ||
| 7841 | 9년 전 | 354 | ||
| 7840 | 9년 전 | 362 | ||
| 7839 | 9년 전 | 395 | ||
| 7838 | 9년 전 | 479 | ||
| 7837 | 9년 전 | 320 | ||
| 7836 | 9년 전 | 360 | ||
| 7835 | 9년 전 | 442 | ||
| 7834 |
|
9년 전 | 1170 | |
| 7833 | 9년 전 | 374 | ||
| 7832 | 9년 전 | 371 | ||
| 7831 | 9년 전 | 505 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기