Working with Larave 5.4, I have a table built with vue.
Each row in the table has this form:
<form @submit.prevent="submitForm" class="status-form" action="'/orders/' + row.Id + '/edit'" method="post">
<input type="hidden" name="status" value="2">
<button type="submit" class="btn btn-success btn-sm">Sent</button>
</form>
My Route: Route::resource('orders', 'OrderController', ['except => show']);
When the Sent button is clicked, I want to submit the form with AJAX.
My Ajax call:
$.ajax({
type: "PATCH",
headers: { 'X-CSRF-TOKEN' : $('meta[name=_token]').attr('content') },
url: $(this).attr('action'),
data: { 'status': 2 },
success: function(data) {
alert($(this).attr('action'));
}
});
When I click the Sent button, I get this in Firebug:
PATCH http://ift.tt/2oxDC1G 405 Method Not Allowed
It looks like, it does not get the form's action correctly. How do I get the form's action from the form, in the ajax call?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire