我有两个链接的AJAX调用。
$.ajax({
url: '/reservation/order',
type: 'POST',
data: {
"_token": "{{ csrf_token() }}",
"check_in": checkIn,
"check_out": checkOut,
"type_payment": "xxxx",
"total_nights": totalNights,
"total_guests": totalGuests,
"total_rooms": +totalRooms,
"total_amount": +totalAmount,
"booking_data": bookingData,
"first_name": firstName,
"last_name": lastName,
"company_name": companyName,
"address": address,
"city": townCity,
"country": country,
"email": email,
"phone": phone,
"guest_remark": guestRemark,
"room_rates": formattedRoomRate
},
dataType: 'json'
}).done(function(response){
orderId = response
proceedToPayment(orderId, "xxxx")
})
继续付款是第二次AJAX
function proceedToPayment(orderId, paymentType){
$.ajax({
url: '/reservation/payment',
type: 'POST',
data: {
"_token": "{{ csrf_token() }}",
"payment_type": paymentType,
"order_id": orderId,
"cust_ip": custIP,
"cust_name": firstName,
"cust_email": email,
"cust_phone": phone
},
dataType: 'json',
success: function(response){
console.log("test")
console.log(response)
window.location.href(response);
}
})
}
inspect元素中的网络选项卡告诉我,我已按顺序成功触发ajax。我可以看到服务器返回的值是正确的值。 但是,我无法访问第二次AJAX调用返回的响应。 这是为什么?或者有没有办法在服务器上返回重定向? 哪一个更好?