To convert the given line to AJAX, you can use the Axios library to make a GET request to the specified route with the necessary data. Here's an example of how you can modify the existing code to achieve this:
axios.get('{{ route('product.warranty.save', [$product->id, $warranty->id]) }}', {
date: newDate,
product_id: this.product_id,
warranty_id: this.warranty_id,
})
.then(response => {
console.log('Response:', response.data);
// handle the response as needed
})
.catch(error => {
console.log('Error:', error);
// handle the error as needed
});
This code should be placed inside the watch property of the Vue instance, so that it gets executed whenever the date property changes. You can remove the existing window.location.href line, as it is no longer needed.
Note that you'll need to include the Axios library in your HTML file, either by downloading it and linking to it locally, or by using a CDN. Here's an example of how you can include it using a CDN:
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>