I'm using a form like this:
<form name="mapping_marc" method="post" id="mapping_marc">
<?php foreach ($all_properties_id as $compound_name => $sub_properties) {?>
<div class='form-group'>
<label class='col-md-12 col-sm-12 meta-title no-padding' name="<?= $compound_name?>" id="<?= $compound_name?>"> <?= $compound_name?> </label>
<?php foreach ($sub_properties as $name => $id){?>
<label class='col-md-6 col-sm-12 meta-title no-padding'style="text-indent: 5%;"> <?= $name?> </label>
<div class='col-md-6 col-sm-12 meta-value'>
<select name="<?= $name ?>" class='data form-control' id="<?= $name ?>">
<?php foreach ($all_marc_fields as $field) { ?>
<option name="<?= $field ?>" id="<?= $field ?>" value="<?= $field ?>"><?= $field ?></option>
<?php } ?>
</select>
</div>
<?php } ?>
</div>
<?php } ?>
<button type="submit" class="btn btn-primary btn-lg tainacan-blue-btn-bg pull-right" id="mapping_save"><?php _e("Save", "tainacan"); ?></button>
</form>
And JQuery like this:
$("#mapping_marc").submit(function (event) {
event.preventDefault();
$('#modalImportLoading').modal('show');
$('#progressbarmapas').remove();
$.ajax({
url: $('#src').val() + '/controllers/collection/collection_controller.php?operation=save_mapping_marc',
type: 'POST',
data: {form: new FormData(this), collection_id: $("#collection_id").val()},
success: function (elem) {
if(elem.result)
{
window.location = elem.url;
}
}
});
});
The form is inserted through a WordPress action. That way JQuery does not find the form but its me put an onclick on the form button that calls a function that executes this jquery so I can find the form but the new FormData (this) operation returns me an error. What could be causing JQuery not to find the form?