function buyItem(itemId) {
if ($("#buyItem").is(":disabled") == false) {
$("#buyItem").prop("disabled", true);
var csrf_token = $('meta[name="csrf-token"]').attr('content');
$.post('/core/func/api/catalog/post/buyItem.php', {
csrf: csrf_token,
itemId: itemId
})
.done(function(response) {
console.log(response);
if (response == "error") {
$("#iStatus").html("
Could not buy this item.
");
}else{
$("#iStatus").html("You have bought this item!
");
$("#buyItem").text("Already owned");
if (cType == "coins")
$("#userCoins").html(response);
if (cType == "posties")
$("#userPosties").html(response);
}
})
.fail(function() {
$("#iStatus").html("Could not buy this item because a network error occurred. Try again later.
");
});
}
}
function deleteItem(itemId) {
if ($("#deleteItem").is(":disabled") == false) {
$("#deleteItem").prop("disabled", true);
var csrf_token = $('meta[name="csrf-token"]').attr('content');
$.post('/core/func/api/catalog/post/deleteItem.php', {
csrf: csrf_token,
itemId: itemId
})
.done(function(response) {
console.log(response);
if (response == "error") {
$("#iStatus").html("Could not delete this item.
");
}else if (response == "success") {
window.location = "/catalog/";
}else{
$("#iStatus").html("Could not delete this item because a network error occurred. Try again later.
");
}
})
.fail(function() {
$("#iStatus").html("Could not delete this item because a network error occurred. Try again later.
");
});
}
}