#900 add error option in exec_json, exec_html

This commit is contained in:
akasima 2014-08-13 11:21:03 +09:00
parent 5ca223ec2b
commit eb3da2617e
3 changed files with 165 additions and 65 deletions

View file

@ -1650,6 +1650,7 @@ function xml2json(xml, tab, ignoreAttrib) {
if(typeof(xeVid)!='undefined') $.extend(data,{vid:xeVid}); if(typeof(xeVid)!='undefined') $.extend(data,{vid:xeVid});
try {
$.ajax({ $.ajax({
type: "POST", type: "POST",
dataType: "json", dataType: "json",
@ -1673,8 +1674,31 @@ function xml2json(xml, tab, ignoreAttrib) {
} }
if($.isFunction(callback_sucess)) callback_sucess(data); if($.isFunction(callback_sucess)) callback_sucess(data);
},
error: function(xhr, textStatus) {
$(".wfsr").hide();
var msg = '';
if (textStatus == 'parsererror') {
msg = 'The result is not valid JSON :\n-------------------------------------\n';
if(xhr.responseText === "") return;
msg += xhr.responseText.replace(/<[^>]+>/g, '');
} else {
msg = textStatus;
}
try{
console.log(msg);
} catch(ee){}
} }
}); });
} catch(e) {
alert(e);
return;
}
} }
}; };
@ -1694,6 +1718,7 @@ function xml2json(xml, tab, ignoreAttrib) {
if(show_waiting_message) $(".wfsr").html(waiting_message).show(); if(show_waiting_message) $(".wfsr").html(waiting_message).show();
$.extend(data,{module:action[0],act:action[1]}); $.extend(data,{module:action[0],act:action[1]});
try {
$.ajax({ $.ajax({
type:"POST", type:"POST",
dataType:"html", dataType:"html",
@ -1703,8 +1728,33 @@ function xml2json(xml, tab, ignoreAttrib) {
$(".wfsr").hide().trigger('cancel_confirm'); $(".wfsr").hide().trigger('cancel_confirm');
self[type](html); self[type](html);
if($.isFunction(func)) func(args); if($.isFunction(func)) func(args);
},
error: function(xhr, textStatus) {
$(".wfsr").hide();
var msg = '';
if (textStatus == 'parsererror') {
msg = 'The result is not valid page :\n-------------------------------------\n';
if(xhr.responseText === "") return;
msg += xhr.responseText.replace(/<[^>]+>/g, '');
} else {
msg = textStatus;
} }
try{
console.log(msg);
} catch(ee){}
}
}); });
} catch(e) {
alert(e);
return;
}
} }
}; };

2
common/js/xe.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -414,6 +414,7 @@ function xml2json(xml, tab, ignoreAttrib) {
if(typeof(xeVid)!='undefined') $.extend(data,{vid:xeVid}); if(typeof(xeVid)!='undefined') $.extend(data,{vid:xeVid});
try {
$.ajax({ $.ajax({
type: "POST", type: "POST",
dataType: "json", dataType: "json",
@ -437,8 +438,31 @@ function xml2json(xml, tab, ignoreAttrib) {
} }
if($.isFunction(callback_sucess)) callback_sucess(data); if($.isFunction(callback_sucess)) callback_sucess(data);
},
error: function(xhr, textStatus) {
$(".wfsr").hide();
var msg = '';
if (textStatus == 'parsererror') {
msg = 'The result is not valid JSON :\n-------------------------------------\n';
if(xhr.responseText === "") return;
msg += xhr.responseText.replace(/<[^>]+>/g, '');
} else {
msg = textStatus;
}
try{
console.log(msg);
} catch(ee){}
} }
}); });
} catch(e) {
alert(e);
return;
}
} }
}; };
@ -458,6 +482,7 @@ function xml2json(xml, tab, ignoreAttrib) {
if(show_waiting_message) $(".wfsr").html(waiting_message).show(); if(show_waiting_message) $(".wfsr").html(waiting_message).show();
$.extend(data,{module:action[0],act:action[1]}); $.extend(data,{module:action[0],act:action[1]});
try {
$.ajax({ $.ajax({
type:"POST", type:"POST",
dataType:"html", dataType:"html",
@ -467,8 +492,33 @@ function xml2json(xml, tab, ignoreAttrib) {
$(".wfsr").hide().trigger('cancel_confirm'); $(".wfsr").hide().trigger('cancel_confirm');
self[type](html); self[type](html);
if($.isFunction(func)) func(args); if($.isFunction(func)) func(args);
},
error: function(xhr, textStatus) {
$(".wfsr").hide();
var msg = '';
if (textStatus == 'parsererror') {
msg = 'The result is not valid page :\n-------------------------------------\n';
if(xhr.responseText === "") return;
msg += xhr.responseText.replace(/<[^>]+>/g, '');
} else {
msg = textStatus;
} }
try{
console.log(msg);
} catch(ee){}
}
}); });
} catch(e) {
alert(e);
return;
}
} }
}; };