function callPostAjax(element, code, gameId, vCode) {
$(element).text("Sending..");
$.post("redeem.php", //Required URL of the page on server
{ "redeemcode": code, "gameid": gameId, "vcode": vCode },
function (response, status) { // Required Callback Function
var result = jQuery.parseJSON(response);
$(element).text(result.message)
}).fail(function (xhr, status, error) {
$(element).text('error');
console.error(error);
});
}
$("#babon").click(function () {
var code = $('#rcode').val();
callPostAjax('span.babon', code, "4548211", "87856");
});
$("#anik").click(function () {
var code = $('#rcode').val();
callPostAjax('span.anik', code, "54489231", "56465");
});
$("#abir").click(function () {
var code = $('#rcode').val();
callPostAjax('span.abir', code, "8798456", "78542");
});
$("#aurko").click(function () {
var code = $('#rcode').val();
callPostAjax('span.aurko', code, "548745612", "24875");
});
$("#af").click(function () {
var code = $('#rcode').val();
callPostAjax('span.af', code, "9887254", "82499");
});