Hi, I have a "photos" table, and a custom page which shows some photos. With every photo there is an icon to delete it.
I want to let the user to click the icon, request a confirmation, and if yes deletes the image and refreshes the page.
The click generates a 401 Unauthorized error. Do I have to create the JWT? Is there any way to reuse the current sessione JWT?
var photos=ExecuteRows("SELECT * FROM photos;");
foreach (Dictionary<string, object> img in photos) {
@<p>
@img["PhotoTitle"]
<a href="#" class="deleteimg" data-id="@img["PhotoID"]"><i class="fa fa-trash"></i></a>
</p>
}
<script>
$('.deleteimg').click(function(){
$.get("api/delete/photos/" + $(this).data('id'), function(res) {
if (res && res.success) {
var row = res[object];
alert(JSON.stringify(row)); // Show output JSON
location.reload();
} else {
alert(res.failureMessage);
}
});
});
</script>