219 lines
6.2 KiB
JavaScript
219 lines
6.2 KiB
JavaScript
// $.ajax Call : Parameter( call URL, request Param, call success data(html) append Target, call Method, callback Function);
|
|
|
|
var ajaxResponse = null;
|
|
var homeURL = "../../";
|
|
|
|
function ajaxCall(url, obj, target, method, func, exceptionfunc, errorfunc){
|
|
$.ajax({
|
|
url: url,
|
|
type: method,
|
|
data: obj,
|
|
success: function(response, textStatus, jqXHR){
|
|
//alert("textStatus: "+textStatus+"\n jqXHR : "+jqXHR+"\n response : "+response);
|
|
if(target){
|
|
$(target).html(function (index, html){
|
|
if(response == ""){
|
|
$(location).attr('href', homeURL);
|
|
return "";
|
|
}
|
|
return html = response;
|
|
});
|
|
}else{
|
|
//console.log("target If Scope : "+response);
|
|
}
|
|
|
|
if(func){
|
|
if(target){
|
|
eval(func);
|
|
}else{
|
|
if(typeof response == "object"){
|
|
//console.log("func If Scope [object] : "+response);
|
|
ajaxResponse = response;
|
|
eval(func);
|
|
}else if(typeof response == "string"){
|
|
if(response == "success"){
|
|
//ajax Call Success~!
|
|
//console.log("response : "+response);
|
|
eval(func);
|
|
}else if(response == "1"){
|
|
//ajax Call Success~!
|
|
//console.log("response : "+response);
|
|
eval(func);
|
|
}else if(response == "0"){
|
|
//ajax Exception~!
|
|
//console.log("response : "+response);
|
|
if(errorfunc){
|
|
eval(errorfunc);
|
|
}else{
|
|
alert("exception...");
|
|
}
|
|
}else if(response == "2"){
|
|
//ajax Exception~!
|
|
//console.log("response : "+response);
|
|
if(exceptionfunc){
|
|
eval(exceptionfunc);
|
|
}else{
|
|
alert("오류가 발생하였습니다.\n관리자에게 문의 바랍니다.");
|
|
}
|
|
}else{
|
|
//ajax Exception~!
|
|
//console.log("response : "+response);
|
|
if(errorfunc){
|
|
eval(errorfunc);
|
|
}else{
|
|
alert("exception...");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}else{
|
|
}
|
|
},
|
|
complete: function(){
|
|
//alert("comment complete");
|
|
},error:function(){
|
|
alert("Web Service Error.");
|
|
}
|
|
});
|
|
}
|
|
|
|
function ajaxCallJson(url, obj, target, method, func, exceptionfunc, errorfunc){
|
|
$.ajax({
|
|
url: url,
|
|
type: method,
|
|
//dataType : "json",
|
|
data: obj,
|
|
success: function(response, textStatus, jqXHR){
|
|
//alert("textStatus: "+textStatus+"\n jqXHR : "+jqXHR+"\n response : "+response);
|
|
if(target){
|
|
$(target).html(function (index, html){
|
|
if(response == ""){
|
|
$(location).attr('href', homeURL);
|
|
return "";
|
|
}
|
|
return html = response;
|
|
});
|
|
}else{
|
|
//console.log("target If Scope : "+response);
|
|
}
|
|
|
|
//alert("Result Call back Function >> func : "+func);
|
|
if(func){
|
|
//alert("func If Scope >> target : "+target);
|
|
//console.log("func If Scope >> target : "+target);
|
|
if(target){
|
|
eval(func);
|
|
}else{
|
|
if(typeof response == "object"){
|
|
//alert("func If Scope [object] : "+response);
|
|
//console.log("func If Scope [object] : "+response);
|
|
ajaxResponse = response;
|
|
eval(func);
|
|
}else if(typeof response == "string"){
|
|
if(response == "success"){
|
|
//ajax Call Success~!
|
|
//console.log("response : "+response);
|
|
eval(func);
|
|
}else if(response.length > 0){
|
|
//alert("response : " + response);
|
|
ajaxResponse = response;
|
|
eval(func);
|
|
}else{
|
|
//ajax Exception~!
|
|
//console.log("response : "+response);
|
|
if(errorfunc){
|
|
eval(errorfunc);
|
|
}else{
|
|
alert("exception...");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}else{
|
|
}
|
|
},
|
|
complete: function(){
|
|
//alert("comment complete");
|
|
},error:function(){
|
|
alert("Web Service Error.");
|
|
}
|
|
});
|
|
}
|
|
|
|
function ajaxCall_nonError(url, obj, target, method, func, exceptionfunc, errorfunc){
|
|
$.ajax({
|
|
url: url,
|
|
type: method,
|
|
data: obj,
|
|
success: function(response, textStatus, jqXHR){
|
|
//alert("textStatus: "+textStatus+"\n jqXHR : "+jqXHR+"\n response : "+response);
|
|
if(target){
|
|
$(target).html(function (index, html){
|
|
if(response == ""){
|
|
$(location).attr('href', homeURL);
|
|
return "";
|
|
}
|
|
return html = response;
|
|
});
|
|
}else{
|
|
//console.log("target If Scope : "+response);
|
|
}
|
|
|
|
if(func){
|
|
if(target){
|
|
eval(func);
|
|
}else{
|
|
if(typeof response == "object"){
|
|
//console.log("func If Scope [object] : "+response);
|
|
ajaxResponse = response;
|
|
eval(func);
|
|
}else if(typeof response == "string"){
|
|
if(response == "success"){
|
|
//ajax Call Success~!
|
|
//console.log("response : "+response);
|
|
eval(func);
|
|
}else if(response == "1"){
|
|
//ajax Call Success~!
|
|
//console.log("response : "+response);
|
|
eval(func);
|
|
}else if(response == "0"){
|
|
//ajax Exception~!
|
|
//console.log("response : "+response);
|
|
if(errorfunc){
|
|
eval(errorfunc);
|
|
}else{
|
|
alert("exception...");
|
|
}
|
|
}else if(response == "2"){
|
|
//ajax Exception~!
|
|
//console.log("response : "+response);
|
|
if(exceptionfunc){
|
|
eval(exceptionfunc);
|
|
}else{
|
|
alert("오류가 발생하였습니다.\n관리자에게 문의 바랍니다.");
|
|
}
|
|
}else if(response.length > 0){
|
|
//alert("response : " + response);
|
|
ajaxResponse = response;
|
|
eval(func);
|
|
}else{
|
|
//ajax Exception~!
|
|
//console.log("response : "+response);
|
|
if(errorfunc){
|
|
eval(errorfunc);
|
|
}else{
|
|
alert("exception...");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}else{
|
|
}
|
|
},
|
|
complete: function(){
|
|
//alert("comment complete");
|
|
},error:function(){
|
|
//alert("Web Service Error.");
|
|
}
|
|
});
|
|
} |