24 * - @method: name of JSON-RPC procedure to call |
24 * - @method: name of JSON-RPC procedure to call |
25 * - @options: additional JSON-RPC procedure parameters |
25 * - @options: additional JSON-RPC procedure parameters |
26 * - @callback: name of a callback which will be called on server response |
26 * - @callback: name of a callback which will be called on server response |
27 */ |
27 */ |
28 post: function(url, method, data, options, callback) { |
28 post: function(url, method, data, options, callback) { |
29 ams.ajax.check($.xmlrpc, |
29 ams.ajax && ams.ajax.check($.xmlrpc, |
30 ams.baseURL + 'ext/jquery-xmlrpc' + ams.devext + '.js', |
30 ams.baseURL + 'ext/jquery-xmlrpc' + ams.devext + '.js', |
31 function() { |
31 function() { |
32 if (typeof(options) === 'function') { |
32 if (typeof (options) === 'function') { |
33 callback = options; |
33 callback = options; |
34 options = {}; |
34 options = {}; |
35 } |
35 } else if (!options) { |
36 else if (!options) { |
36 options = {}; |
37 options = {}; |
37 } |
38 } |
38 if (typeof (callback) === 'undefined') { |
39 if (typeof(callback) === 'undefined') { |
39 callback = options.callback; |
40 callback = options.callback; |
40 } |
41 } |
41 if (typeof (callback) === 'string') { |
42 if (typeof(callback) === 'string') { |
42 callback = ams.getFunctionByName(callback); |
43 callback = ams.getFunctionByName(callback); |
43 } |
44 } |
44 delete options.callback; |
45 delete options.callback; |
|
46 |
45 |
47 var result; |
46 var result; |
48 var defaults = { |
47 var defaults = { |
49 url: ams.xmlrpc.getAddr(url), |
48 url: ams.xmlrpc.getAddr(url), |
50 methodName: method, |
49 methodName: method, |
51 params: data, |
50 params: data, |
52 success: callback || function(response /*, status, xhr*/) { |
51 success: callback || function(response /*, status, xhr*/) { |
53 result = response; |
52 result = response; |
54 }, |
53 }, |
55 error: ams.error.show |
54 error: ams.error && ams.error.show |
56 }; |
55 }; |
57 var settings = $.extend({}, defaults, options); |
56 var settings = $.extend({}, defaults, options); |
58 $.xmlrpc(settings); |
57 $.xmlrpc(settings); |
59 return result; |
58 return result; |
60 }); |
59 }); |
61 } |
60 } |
62 }; |
61 }; |
63 |
62 |
64 })(jQuery, this); |
63 })(jQuery, this); |