if (!ssp) var ssp = {};
--*
* 기본적인 ajax Class
* @param url
--
ssp.ajax = function (url) {
this.url = url;
this.param = "";
}
--*
* ajax에 원하는 파라메터 값을 setting한다.
* @param name - parameter 이름
* @param value - parameter 값
* @return
--
ssp.ajax.prototype.addParam = function (name, value) {
if(this.param.length == 0){
this.param += name + "=" + value;
} else {
this.param += "&" + name + "=" + value;
}
}
--*
* Ajax를 수행한다.
* @param callBack - Ajax 수행 후 실행되는 함수
* @return
--
ssp.ajax.prototype.send = function (callBack){
$.ajax({
type: "POST",
url: this.url,
data: this.param,
dataType: "json",
success: function(msg) {
if(msg==null){
return;
}
if(msg[0].Error){
alert(msg[0].Error);
} else {
//CallBack Function이 없을경우 Error처리를 한다.
try {
return eval(callBack+'(msg)');
} catch (err) {
//Error msg출력
alert(err);
alert("CallBack Method가 없습니다.");
}
}
}
});
}
--*
* Common Code용 ComboBox 구성(Ajax 이용)
* @param url : 공통 url
* @param groupCode : 그룹코드
* @param targetId : 만들어질 comboBox ID
* @return
--
ssp.ajax.prototype.cmmnCodeAjax = function(groupCode, targetId, value){
$.ajax({
type: "POST",
url: this.url,
data: "cmmnCode="+groupCode,
dataType: "json",
success: function(msg) {
if(msg==null){
return;
}
if(msg[0].Error){
alert(msg[0].Error);
} else {
//CallBack Function이 없을경우 Error처리를 한다.
try {
$("#"+ targetId).html("");
for(var i=0 ; i < msg.length ; i++) {
//value를 입력받아 해당 값과 같을 경우 select한다.
if(value != null && value == msg[i].cmmnDetailCode ){
$("#"+ targetId).append("<option value='"+ msg[i].cmmnDetailCode +"' selected >"+ msg[i].detailCodeNm +"</option>" );
} else {
$("#"+ targetId).append("<option value='"+ msg[i].cmmnDetailCode +"'>"+ msg[i].detailCodeNm +"</option>" );
}
}
} catch (err) {
//Error msg출력
alert(err);
alert("CallBack Method가 없습니다.");
}
}
}
});
}
최근 덧글