1
0
mirror of https://github.com/mwalbeck/pushjet-webinterface.git synced 2024-11-23 14:57:33 +00:00
pushjet-webinterface/static/js/service.js
2017-01-13 14:07:26 +01:00

64 lines
1.6 KiB
JavaScript
Executable File

// Highlight current tab
$('#myTabs a[href="#service"]').tab('show')
// Service Ajax requests
$('#create').submit(function (e) {
e.preventDefault();
$.ajax({
method: "POST",
url: "/service",
data: $("#create").serialize(), // serializes the form's elements.
success: function(data)
{
$.each(data["service"], function(key, value) {
$("#result").append(key + ": " + value + "<br>");
});
$("#result").append("<br>");
}
});
});
$('#getinfo').submit(function (e) {
e.preventDefault();
$.ajax({
method: "GET",
url: "/service",
data: $("#getinfo").serialize(), // serializes the form's elements.
success: function(data)
{
$.each(data["service"], function(key, value) {
$("#result").append(key + ": " + value + "<br>");
});
$("#result").append("<br>");
}
});
});
$('#update').submit(function (e) {
e.preventDefault();
$.ajax({
method: "PATCH",
url: "/service",
data: $("#update").serialize(), // serializes the form's elements.
success: function(data)
{
$("#result").append(data + "<br>"); // show response from the php script.
}
});
});
$('#delete').submit(function (e) {
e.preventDefault();
$.ajax({
method: "DELETE",
url: "/service",
data: $("#delete").serialize(), // serializes the form's elements.
success: function(data)
{
$("#result").append(data + "<br>"); // show response from the php script.
}
});
});