Ya logre hacer que envie la forma, pero ahora, no me actualiza si el resultado es positivo:
Código Javascript
:
Ver original$(document).ready(function() {
$('#newsForm').bootstrapValidator({
// Only disabled elements are excluded
// The invisible elements belonging to inactive tabs must be validated
excluded: [':disabled'],
trigger: 'focus blur keyup',
feedbackIcons: {
valid: 'icon-ok',
invalid: 'icon-remove',
validating: 'icon-refresh'
},
fields: {
//field data here.
}
})
// Called when a field is invalid
.on('error.field.bv', function(e, data) {
// data.element --> The field element
var $tabPane = data.element.parents('.tab-pane'),
tabId = $tabPane.attr('id');
$('a[href="#' + tabId + '"][data-toggle="tab"]')
.parent()
.find('i')
.removeClass('fa-check')
.addClass('fa-times');
})
// Called when a field is valid
.on('success.field.bv', function(e, data) {
// data.bv --> The BootstrapValidator instance
// data.element --> The field element
var $tabPane = data.element.parents('.tab-pane'),
tabId = $tabPane.attr('id'),
$icon = $('a[href="#' + tabId + '"][data-toggle="tab"]')
.parent()
.find('i')
.removeClass('fa-check fa-times');
// Check if the submit button is clicked
if (data.bv.getSubmitButton()) {
// Check if all fields in tab are valid
var isValidTab = data.bv.isValidContainer($tabPane);
$icon.addClass(isValidTab ? 'fa-check' : 'fa-times');
}
}).on('success.form.bv', function(e) {
submit();
});
});
function submit(){
$('#newsForm').submit(function(){
$.post("enviar_datos.php", $('#newsForm').serialize(),function(data){
if (data.success){
$('#newsForm').find('.well').slideUp('normal', function (){
$('#newsForm').html(data);
});
}else{
window.alert('Failed');
}
}, 'json');
return false;
});
}
help please? :3