I need to send 2 values to my codeigniter controller complete the request. But I failed in all attempts.
My Controller need to receive:
$token = $this->input->post('cc_token');
$hash = $this->input->post('sender_hash');
Ajax
$(document).ready(function ({
var sender_hash = myfunction.getSenderHash();
var card_token = myFunction.createCardToken({
cardNumber: "4111111111111111",
brand: 'visa',
cvv: "123",
expirationMonth: "12",
expirationYear: "2030",
success: function (response) {
},
error: function (response) {
console.log(response);
}
});
$("#submit").click(function () {
$.ajax({
url: '<?php echo $details->id?>',
type: 'POST',
data: 'cc_token=' + card_token + '&sender_hash=' + sender_hash,
beforeSend: function () {
console.log("Your request is being processed. Wait...");
},
success: function (data) {
console.log("Thank you for donating. Your request has been successfully processed!");
},
error: function (data) {
console.log("There was an error sending the data. Try again.")
}
});
});
});
But the post was not send to controller. What i'm doing wrong? If i put these values in input, works fine, but I don't wanna to do that, because this is not the right way.