Commit f5d3c897 authored by Lukas Schmitt's avatar Lukas Schmitt

u6

parent 5ece040c
......@@ -2,7 +2,7 @@
<html>
<head>
<title>Übung 6</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="/site/style.css">
<script src="/jquery/jquery.js"></script>
<script src="/site/script.js"></script>
<script type="text/javascript" src="/popper/popper.js"></script>
......@@ -20,7 +20,7 @@
<hr>
<h3 class="section-heading"></h3>
<input id="secMaxAge" type="number" placeholder="Sekunden">
<button id="secButton" class="btn btn- btn-warning">maximales Alter setzen</button>
<button id="secButton" class="btn btn-info">maximales Alter setzen</button>
<br><br>
<hr>
<h3 class="section-heading">Session loeschen</h3>
......
$(() => {
$("#container").text("jQuery läuft...");
$(function () {
//Reset MaxAge from Cookie
$('#resetMaxAge').on('click', function () {
$.ajax({
url: "http://localhost:8080/maxage",
type: "DELETE",
dataType: "json",
success: (data) => {
alert("Set MaxAge to null");
//$('#placeholderResetMaxAge').append("<p class='lead'>MaxAge set to null</p>");
},
error: (jqXHR, Status, error) => {
alert(error)
}
});
});
$('#secButton').on('click', function () {
let secMaxAgeInput: JQuery = $('#secMaxAge');
if (secMaxAgeInput.val() as string !== "") {
$.ajax({
url: "http://localhost:8080/maxage/" + secMaxAgeInput.val() as string,
type: "POST",
dataType: "json",
success: (data) => {
alert("Set MaxAge to " + Number(secMaxAgeInput.val())*1000);
secMaxAgeInput.val("");
},
error: (jqXHR, Status, error) => {
alert(error);
secMaxAgeInput.val("");
}
});
}
});
$('#delSession').on('click', function () {
$.ajax({
url: "http://localhost:8080/session",
type: "DELETE",
dataType: "json",
success: (data) => {
alert("Session deleted");
},
error: (jqXHR, Status, error) => {
alert(error)
}
});
});
$('#redSession').on('click', function () {
$.ajax({
url: "http://localhost:8080/session",
type: "GET",
dataType: "json",
success: (data) => {
let strings: string = JSON.stringify(data.cookie);
alert(strings);
},
error: (jqXHR, Status, error) => {
alert(error)
}
});
});
$('#setNewValue').on('click', function () {
let keyInput: JQuery = $('#key');
let valueInput: JQuery = $('#value');
$.ajax({
url: "http://localhost:8080/variable/" + keyInput.val() + "/" + valueInput.val(),
type: "POST",
dataType: "json",
success: (data) => {
alert("New Data:\nKey: " + keyInput.val() + "\nValue: " + valueInput.val());
keyInput.val("");
valueInput.val("");
},
error: (jqXHR, Status, error) => {
alert(error);
keyInput.val("");
valueInput.val("");
}
});
});
$('#delKeyPair').on('click', function () {
let delKeyInput: JQuery = $('#delkey');
$.ajax({
url: "http://localhost:8080/variable/" + delKeyInput.val(),
type: "DELETE",
dataType: "json",
success: (data) => {
alert("Key Pair " + delKeyInput.val() + " was deleted");
delKeyInput.val("");
},
error: (jqXHR, Status, error) => {
alert(error);
delKeyInput.val("");
}
});
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment