2018-06-04 00:06:17 +08:00
|
|
|
(function (global, document) {
|
2018-06-24 10:01:21 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
(document);
|
2018-06-04 00:06:17 +08:00
|
|
|
|
|
|
|
// Performs a JSON POST request to the given url with the given data and
|
|
|
|
// calls the callback function with the JSON response.
|
|
|
|
global.post = function(url, json, callback) {
|
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
type: "POST",
|
|
|
|
data: JSON.stringify(json),
|
|
|
|
success: function(data) {
|
|
|
|
var resp = JSON.parse(data);
|
|
|
|
callback(resp);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Performs a GET request and calls the callback function with the JSON
|
|
|
|
// response.
|
|
|
|
global.get = function(url, callback) {
|
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
type: "GET",
|
|
|
|
success: function(data) {
|
|
|
|
var resp = JSON.parse(data);
|
|
|
|
callback(resp);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-12-20 13:48:43 +08:00
|
|
|
} (window.commento, document));
|