1
0
Fork 0
mirror of https://github.com/mwalbeck/pushjet-webinterface.git synced 2025-04-29 06:50:06 +00:00
pushjet-webinterface/static/js/message.js
2017-01-13 14:07:26 +01:00

51 lines
1.4 KiB
JavaScript
Executable file

// Highlight current tab
$('#myTabs a[href="#message"]').tab('show')
// Message Ajax requests
$('#send').submit(function (e) {
e.preventDefault();
$.ajax({
method: "POST",
url: "/message",
data: $("#send").serialize(), // serializes the form's elements.
success: function(data)
{
$("#result").append(data + "<br>"); // show response from the php script.
}
});
});
$('#unread').submit(function (e) {
e.preventDefault();
$.ajax({
method: "GET",
url: "/message",
data: $("#unread").serialize(), // serializes the form's elements.
success: function(data)
{
$("#result").append("<br>");
$.each(data["messages"], function( index, obj ) {
$.each(obj, function(key, value) {
$("#result").append(key + ": " + value + "<br>");
});
$("#result").append("<br>");
});
$("#result").append("<br>");
}
});
});
$('#markread').submit(function (e) {
e.preventDefault();
$.ajax({
method: "DELETE",
url: "/message",
data: $("#markread").serialize(), // serializes the form's elements.
success: function(data)
{
$("#result").append(data + "<br>"); // show response from the php script.
}
});
});