It seems to be that there is no option to specify the content-type header, when submitting an alpacajs form.
All forms are submitted as application/x-www-form-urlencoded which is a little strange to my taste, since Alpaca is all about json. It's also not listed in the documentation.
So my question: how do I submit my form as JSON content type?
Laravel states the following in it's documentation "When sending JSON requests to your application, you may access the JSON data via the input method as long as the Content-Type header of the request is properly set to application/json".
Something like
var data = $('#my-form').alpaca().getValue();
$.ajax('/endpoint', {
contentType: 'application/json',
data: JSON.stringify(data)
})
Or alternatively
$('#my-form').alpaca({
schema: {..},
options: {
form: {
buttons: {
submit: {
type: 'button',
click: function(){
var val = this.getValue();
// Repeat ajax call from above.
}
}
}
}
}
})