2014년 9월 23일 화요일

javascript callback with argument

/**

ip 셋팅
id 셋팅

*/

//var jsdom = require("jsdom");
$ = require("jquery");

console.log("Hello world!");
JsTr = function(JsTr,$,undefined){
JsTr.cmd = "";
JsTr.getIpWrap = function(json,callback){
console.log("[JsTr.getIpWrap][assign][start]");
return (function(){
console.log("[JsTr.getIpWrap][run][start]");
getIp(json,callback);
console.log("[JsTr.getIpWrap][run][end]");
});
};

JsTr.getIdWrap = function(json,callback){
console.log("[JsTr.getIdWrap][assign][start]");
return (function(){
console.log("[JsTr.getIdWrap][run][start]");
getId(json,callback);
console.log("[JsTr.getIdWrap][run][end]");
});
};
var ip = "";
var id = "";
JsTr.send = function(serviceId,jsonParam,scb,fcb){
console.log("[JsTr.send][assign][start]");
// 콜백은 역순으로 만들면 된다.

var fRef_getIdWrap = JsTr.getIdWrap(jsonParam,scb,fcb);
var fRef_getIpWrap = JsTr.getIpWrap(jsonParam,fRef_getIdWrap);
//jsonParam += serviceId;
fRef_getIpWrap();
//
};

return JsTr;
}({},$);
JsTr.send("ttttttttttt",'{jsonParam:11}',successCallBack);
function getIp(json,callback){
console.log("[getIp][run][start]");
JsTr.cmd += ",ip:123.22.55.101";
callback();
console.log("[getIp][run][end]"+json);
}
function getId(json,callback){
console.log("[getId][run][start]");
JsTr.cmd += ",id:130.204.77";
callback(JsTr.cmd);
console.log("[getId][run][end]"+json);
}


function successCallBack(ret){
console.log("[successCallBack][run][start]");
console.log(ret);
console.log("[successCallBack][run][end]");
}
function failCallBack(ret){
console.log("[failCallBack][run][start]");
console.log(ret);
console.log("[failCallBack][run][end]");
}

// ref :// http://directwebremoting.org/dwr/documentation/browser/extra-data.html

댓글 없음:

댓글 쓰기

3gb minning

비트코인 골드 -- 마이너 다운로드 :  https://www.bminercontent.com/releases/bminer-v6.0.0-d111154-amd64.zip -- vcruntime140.dll 다운로드  https://www.micr...