1
I have the following form:
<form id="excluir" class="form-horizontal" role="form" method="POST">
<input type="hidden" name="_token" value="s59zI8Ehg0dw2CVnmqpfGgyyuHKJDHSF">
<input type="hidden" name="_method" value="DELETE">
</form>
I am currently using the jQuery statement below to assign an action and submit the form:
$('#excluir').attr('action', '/post/12');
$('#excluir').submit();
However, I don’t want to use a tag id in the form, I want to check if in the form there is an input with the tag name="_method", if yes, I will assign the action and submit the form.
Any idea how to do this search?
So much code... what do you need the callback for? In which case do you need the second check here
typeof callback === 'function' && callback
?– Sergio
If callback is Undefined or different from Function, it will give an error.
– Caio Koiti
What I meant to say is that enough
if( typeof callback === 'function'){
for ifcallback
was afunction
the second condition of&&
is guaranteed, ie is redundant.– Sergio