mirror of
https://gitlab.com/commento/commento.git
synced 2025-06-29 22:56:37 -04:00
frontend: check in html, css, js
This commit is contained in:
31
frontend/js/http.js
Normal file
31
frontend/js/http.js
Normal file
@ -0,0 +1,31 @@
|
||||
(function (global, document) {
|
||||
|
||||
// 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);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
} (window, document));
|
Reference in New Issue
Block a user