4 _App.Ajax = function ()
16 initialize: function ()
21 DOWNLOAD: function (args)
23 var target = !args.direct
26 $('<form id="downloadForm' + this.exportCounter + '" method="get" ' + target + ' action="' + args.url + '">'
27 + '</form>').appendTo('body').submit();
28 $('#downloadForm' + this.exportCounter).remove();
32 EXPORT: function (args)
34 args.data = args.data[0];
36 inputs += '<input type="hidden" name="Contract" value="' + args.data.Contract + '">';
37 for (var group in args.data.Packet)
39 for (var param in args.data.Packet[group])
41 inputs += '<input type="hidden" name="Packet[' + group + '][' + param + ']" value="' + args.data.Packet[group][param] + '">';
44 if (args.data.Options)
46 for (var param in args.data.Options)
48 inputs += '<input type="hidden" name="Options[' + param + ']" value="' + args.data.Options[param] + '">';
51 var target = !args.direct
54 $('<form id="exportForm' + this.exportCounter + '" method="post" ' + target + ' action="' + args.url + '">'
56 + '</form>').appendTo('body').submit();
57 $('#exportForm' + this.exportCounter).remove();
61 JSON: function (args, callback, errorCallback)
65 args.dataType = 'json';
66 args.url = window.location.protocol
67 + '//' + window.location.hostname
68 + ':' + window.location.port
69 + ( args.url.indexOf('/') === 0
72 args.data = JSON.stringify(args.data);
74 .done(function (data) {
75 (undefined != args.id)
76 ? callback(args.id, data)
79 .fail(function (jqXHR, textStatus, errorThrown) {
82 (undefined != args.id)
83 ? errorCallback(args.id, textStatus, errorThrown)
84 : errorCallback(textStatus, errorThrown);
90 SCRIPT: function (args, callback, errorCallback)
93 args.dataType = 'script';
94 args.url = window.location.protocol
95 + '//' + window.location.hostname
96 + ':' + window.location.port
97 + ( args.url.indexOf('/') === 0
101 .done(function (data) {
105 ? callback(args.id, data)
109 .fail(function (jqXHR, textStatus, errorThrown) {
113 ? errorCallback(args.id, textStatus, errorThrown)
114 : errorCallback(textStatus, errorThrown);
120 POST: function (args, callback, errorCallback)
124 args.url = window.location.protocol
125 + '//' + window.location.hostname
126 + ':' + window.location.port
127 + ( args.url.indexOf('/') === 0
131 .done(function (data) {
135 ? callback(args.id, data)
139 .fail(function (jqXHR, textStatus, errorThrown) {
143 ? errorCallback(args.id, textStatus, errorThrown)
144 : errorCallback(textStatus, errorThrown);
150 GET: function (args, callback, errorCallback)
154 args.url = window.location.protocol
155 + '//' + window.location.hostname
156 + ':' + window.location.port
157 + ( args.url.indexOf('/') === 0
161 .done(function (data) {
165 ? callback(args.id, data)
169 .fail(function (jqXHR, textStatus, errorThrown) {
173 ? errorCallback(args.id, textStatus, errorThrown)
174 : errorCallback(textStatus, errorThrown);