This is my ajax script that use in jQuery step library. after get data from Get method in several step correctly and get with this Ajax method correctly :
onFinished: function (event, currentIndex) {
event.preventDefault();
console.log("Finish was clicked !");
var postData = {
CartAddresses: {
Address: $('#reviewAddress').val(),
State: $('#reviewState').val(),
District: $('#reviewDistrict').val(),
ZipCode: $('#reviewZipCode').val()
},
CartDeliveryDateViewModel: {
DeliveryDate: $('#deliveryDate').val(),
DeliveryTime: $('#deliveryTime').val(),
Details: $('#details').val(),
PaymentMethod: $('#paymentMethod').val()
},
Tax: parseFloat($('#tax').val()),
TotalPrice: parseFloat($('#totalPrice').text()),
FinalPrice: parseFloat($('#finalPrice').text())
};
var postDataJson = JSON.stringify(postData);
console.log('postData', postData);
$.ajax({
url: '/UserPanel/Checkout',
type: 'POST',
contentType: 'application/json',
data: postDataJson,
success: function (response) {
console.log('Checkout successful:', response);
},
error: function (xhr, status, error) {
console.error('Checkout failed:', status, error);
alert('Error sending data. Please try again.');
}
});
}`
but in post controller it does not pass to method and all data input are null. All data get correctly and I checked n console but does not get to controller input
`
[Authorize]
[HttpPost(“/UserPanel/Checkout”)]
public IActionResult Checkout ( CheckOutViewModel checkOutViewModel)
{
if (checkOutViewModel != null)
{
bool isCheckoutSuccessful = true;
if (isCheckoutSuccessful)
{
return Json(new { success = true, message = "Checkout completed successfully." });
}
else
{
return Json(new { success = false, message = "There was an error completing the checkout." });
}
}
else
{
return BadRequest("Invalid data received.");
}
}
`