src/pyams_skin/resources/js/ext/jquery-jsonrpc.js
changeset 0 bb4aabe07487
child 43 d366c88a0f88
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_skin/resources/js/ext/jquery-jsonrpc.js	Thu Feb 19 10:59:00 2015 +0100
@@ -0,0 +1,36 @@
+(function ($) {
+
+	$.jsonRpc = $.jsonRpc || function (options) {
+		options.type = options.type || 'GET';
+		var ajaxOptions = {
+			contentType: 'application/json',
+			dataType: options.type == 'GET' ? 'jsonp' : 'json',
+			processData: options.type == 'GET'
+		};
+
+		var data = {
+			version: options.version || '1.0',
+			method: options.method || 'system.listMethods',
+			params: options.params || []
+		};
+		$.each(data, function (i) {
+			delete options[i]
+		});
+
+		function send() {
+			options.data = JSON.stringify(data);
+			if (options.type == 'GET') options.data = {json: options.data};
+			$.ajax($.extend(ajaxOptions, options));
+		}
+
+		if (typeof JSON == 'undefined') {
+			$.getScript('http://www.json.org/json2.js', function () {
+				send()
+			});
+		} else {
+			send();
+		}
+		return $;
+	};
+
+})(jQuery);