; (function () { _App.Ajax = function () { this.initialize(); }; _App.Ajax.prototype = { exportCounter: 0, initialize: function () { }, DOWNLOAD: function (args) { var target = !args.direct ? 'target="_blank"' : ''; $('
').appendTo('body').submit(); $('#downloadForm' + this.exportCounter).remove(); this.exportCounter++; }, EXPORT: function (args) { args.data = args.data[0]; inputs = ''; inputs += ''; for (var group in args.data.Packet) { for (var param in args.data.Packet[group]) { inputs += ''; } } if (args.data.Options) { for (var param in args.data.Options) { inputs += ''; } } var target = !args.direct ? 'target="_blank"' : ''; $('').appendTo('body').submit(); $('#exportForm' + this.exportCounter).remove(); this.exportCounter++; }, JSON: function (args, callback, errorCallback) { args.type = 'POST'; args.dataType = 'json'; args.url = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + ( args.url.indexOf('/') === 0 ? args.url : '/' + args.url); args.data = JSON.stringify(args.data); $.ajax(args) .done(function (data) { (undefined != args.id) ? callback(args.id, data) : callback(data); }) .fail(function (jqXHR, textStatus, errorThrown) { if (errorCallback) { (undefined != args.id) ? errorCallback(args.id, textStatus, errorThrown) : errorCallback(textStatus, errorThrown); } }); }, SCRIPT: function (args, callback, errorCallback) { args.type = 'GET'; args.dataType = 'script'; args.url = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + ( args.url.indexOf('/') === 0 ? args.url : '/' + args.url); $.ajax(args) .done(function (data) { if (callback) { (args.id) ? callback(args.id, data) : callback(data); } }) .fail(function (jqXHR, textStatus, errorThrown) { if (errorCallback) { (args.id) ? errorCallback(args.id, textStatus, errorThrown) : errorCallback(textStatus, errorThrown); } }); }, POST: function (args, callback, errorCallback) { args.type = 'POST'; args.url = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + ( args.url.indexOf('/') === 0 ? args.url : '/' + args.url); $.ajax(args) .done(function (data) { if (callback) { (args.id) ? callback(args.id, data) : callback(data); } }) .fail(function (jqXHR, textStatus, errorThrown) { if (errorCallback) { (args.id) ? errorCallback(args.id, textStatus, errorThrown) : errorCallback(textStatus, errorThrown); } }); }, GET: function (args, callback, errorCallback) { args.type = 'GET'; args.url = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + ( args.url.indexOf('/') === 0 ? args.url : '/' + args.url); $.ajax(args) .done(function (data) { if (callback) { (args.id) ? callback(args.id, data) : callback(data); } }) .fail(function (jqXHR, textStatus, errorThrown) { if (errorCallback) { (args.id) ? errorCallback(args.id, textStatus, errorThrown) : errorCallback(textStatus, errorThrown); } }); } }; })();