javascript - Error on success form , no url call -
i'm having problems regarding following code, working (form validation) ajax call never used
.find('[name="turmas"]') .multiselect({ onchange: function(element, checked) { $('#eventform').formvalidation('revalidatefield', 'turmas'); } }) .end() .find('[name="doc"]') .multiselect({ enablefiltering: true, includeselectalloption: true, onchange: function(element, checked) { $('#eventform').formvalidation('revalidatefield', 'doc'); } }) .end() .find('[name="dpt"]') .multiselect({ enablefiltering: true, includeselectalloption: true, onchange: function(element, checked) { $('#eventform').formvalidation('revalidatefield', 'dpt'); } }) .end() .find('[name="dominios"]') .multiselect({ enablefiltering: true, includeselectalloption: true, onchange: function(element, checked) { $('#eventform').formvalidation('revalidatefield', 'dominios'); } }) .end() .find('[name="tp"]') .multiselect({ enablefiltering: true, includeselectalloption: true, onchange: function(element, checked) { $('#eventform').formvalidation('revalidatefield', 'tp'); } }) .end() .find('[name="iti"]') .multiselect({ enablefiltering: true, includeselectalloption: true, onchange: function(element, checked) { $('#eventform').formvalidation('revalidatefield', 'iti'); } }) .end() .find('[name="financiamento"]') .multiselect({ enablefiltering: true, includeselectalloption: true, onchange: function(element, checked) { $('#eventform').formvalidation('revalidatefield', 'financiamento'); } }) .end() .on('click', 'button[data-toggle]', function () { var $target = $($(this).attr('data-toggle')); $target.toggle(); if (!$target.is(':visible')) { $('#eventform').data('formvalidation').disablesubmitbuttons(false); } }) .on('change', '[name="seguro"]', function (e) { $('#eventform').formvalidation('revalidatefield', 'custo_seguro'); var seg = $('#eventform').find('[name="seguro"]:checked').val(); console.log(seg); if (seg !== 'sim') { document.getelementbyid("custo_seguro").disabled = true; document.getelementbyid("custo_seguro").value = 0; } else { document.getelementbyid("custo_seguro").disabled = false; } }) .on('success.field.fv', function (e, data) { if (data.field === 'startdate' && !data.fv.isvalidfield('enddate')) { data.fv.revalidatefield('enddate'); } if (data.field === 'enddate' && !data.fv.isvalidfield('startdate')) { data.fv.revalidatefield('startdate'); } if (data.field === 'custo_seguro') { var seg = $('#eventform').find('[name="seguro"]:checked').val(); if (seg !== 'sim') { data.element.closest('.form-group').removeclass('has-success'); data.element.data('fv.icon').hide(); } } }) .on('change', '[name="estadia"]', function (e) { $('#eventform').formvalidation('revalidatefield', 'custo_estadia'); var estadia = $('#eventform').find('[name="estadia"]:checked').val(); console.log(estadia); if (estadia !== 'sim') { document.getelementbyid("custo_estadia").disabled = true; document.getelementbyid("custo_estadia").value = 0; } else { document.getelementbyid("custo_estadia").disabled = false; } }) .on('success.field.fv', function (e, data) { if (data.field === 'custo_estadia') { var estadia = $('#eventform').find('[name="estadia"]:checked').val(); if (estadia !== 'sim') { data.element.closest('.form-group').removeclass('has-success'); data.element.data('fv.icon').hide(); } } }) .find('input[name="seguro"], input[name="estadia"]').icheck({ tap: true, checkboxclass: 'icheckbox_square-red', radioclass: 'iradio_square-red' }) .on('ifchanged', function (e) { var field = $(this).attr('name'); console.log("field: ", field); $('#eventform').formvalidation('revalidatefield', field); }) .on('success.form.fv', function (e) { console.log("aqui"); e.preventdefault(); $("#eventform").modal('hide'); var $form = $(e.target), fv = $form.data('formvalidation'); $.ajax({ url: '/miga/db/dboperations.php', type: 'post', data: $form.serialize(), success: function (data) { var result = data.status; console.log(result); if (result === 'success') { $('#success .modal-body').html('informação: ' + data.message); $('#success').modal('show'); $('#success').on('hidden.bs.modal', function () { window.location.reload(true); }); } else { $('#danger .modal-body').html('informação: ' + data.message); $('#danger').modal('show'); $('#danger').on('hidden.bs.modal', function () { window.location.reload(true); }); } } }); });
i put console log after ajax , can see don't receive information obvious ajax call not working, wrong in code, no errors detected in debugger.
wiki
Comments
Post a Comment