`<button type="button" class="btn btn-primary refund-initiate-btn"
data-prn="{{ $item->PRN }}"
data-rpptxnid="{{ $item->RPPTxnId }}"
data-amount="{{ $item->AMOUNT }}"
style="width: max-content;">Refund Initiate</button>`
I have this button contain all the value which i want to show on controller so for this first i call a ajax to store value than i pass in controller
AJAX
` <script>
$(document).ready(function() {
// Function to handle the "Refund Initiate" button click
$(".refund-initiate-btn").on("click", function() {
var prn = $(this).data("prn");
var rpptxnid = $(this).data("rpptxnid");
var amount = $(this).data("amount");
// Create an object with the data to be sent
var requestData = {
prn: prn,
rpptxnid: rpptxnid,
amount: amount,
};
console.log(requestData);
// Make the API call using AJAX
$.ajax({
url: "{{ route('refundlog') }}",
type: "POST",
data: JSON.stringify(requestData), // Convert data to JSON format
contentType: "application/json", // Set content type to JSON
dataType: "json",
beforeSend: function(xhr) {
xhr.setRequestHeader('X-CSRF-TOKEN', "{{ csrf_token() }}"); // Set CSRF token header
},
success: function(response) {
// Handle the API response here
console.log(response);
// You can process the response here or display it on the page
},
error: function(xhr, status, error) {
console.error(error);
// Handle API error here if any
}
});
});
});
</script>`
Controller
` $prn = $request->input('prn');
$rpptxnid = $request->input('rpptxnid');
$amount = $request->input('amount'); `
all the value i can see perfectly in ajax calling but when it comes to controller it not fetch please can you tell me what is wrong in it
“
2
Answers
I don’t know if it will work for you, but this works for me
I’ve made very basic example for you. It works for me.