Use of fetch is very common but it not going to load new page with data, it just send data and receive data.
How to use it like normal HTML form submit but instead of using name I can send data like fetch and but open new link as form action does. Open New Page.
If i use form action I have to use name attribute but there is some much data so name can be too much for it also it can be array also that is hard pass for using name for.
Is it possible to send data like form html but without name that open a new page with all data which get send via.
Only I want to send an array which post to new page as a json data.
<!-- Here is example of using alpine and using fetch to send data it return whole page but i can't do anything with it -->
<script src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
<div x-data="{order:''}">
<form @submit.prevent="fetch('/user/payment', {method: 'POST', headers:{'Content-Type': 'application/json'},body: JSON.stringify(order)})">
<div class="mt-6">
<button><span>Proceed to RazorPay<br>₹ 747</span>
</button>
</div>
</form>
</div>
<Br>
<Br>
<!-- I like something Like this so action page but here i like to send array of data -->
<form method="POST" action= '/user/payment'>
<input type="text" name="order"/>
<div class="mt-6">
<button><span>Proceed to RazorPay<br>₹ 747</span>
</button>
</div>
</form>
After using fetch, you can change the url of the window like this window.location.replace = your_url.