我有这个脚本:
$('form').each(function validate() { // attach to all form elements on page
$(this).bootstrapValidator({
// initialize plugin on each form
message: 'This value is not valid',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: ''
},
live: 'enabled',
trigger: null,
fields: {
ServiceCategory: {
validators: {
notEmpty: {message: "<?php echo $Missing_Service_Category ?>"},
regexp: {regexp: /^[A-Za-z]/, message: "<?php echo $Wrong_Service_Category ?>"},
}
},
}
})
.on('success.form.bv', function(e, data) {
// Prevent form submission
e.preventDefault();
// Get the form instance
var $form = $(e.target);
// Get the BootstrapValidator instance
var bv = $form.data('bootstrapValidator');
// Use Ajax to submit form data
// Use Ajax to submit form data
$.ajax({
url: $form.attr('action'),
type: 'POST',
contentType: "application/x-www-form-urlencoded;charset=utf-8",
data: $form.serialize(),
success: function(data){
var parts = data.split('|')
var type = parts[0]
var text = parts[1]
if(type==1){
// If Success type is 1, show success message with type success
$('.top-right').notify({
message: { text: text },
type: 'info',
}).show();
$(".tab-content").load(" .tab-content > *", $(document).ready(function() {
$.ajax({
url: 'scripts.php',
success: function(data) {
$("#scripts").html(data);
}
});
}));
}
else if(type==2){
// If Success type is 1, show success message with type success
$('.top-right').notify({
message: { text: text },
type: 'danger',
}).show();
}
else if(type==3){
// If Success type is 3, print messaage to #ResponseDIV
$('#ResponseDiv').html(text);
}else{
// If Success type is 3, print messaage to #ResponseDIV
$('#ResponseDiv').html(text);
}
},
error: function(xhr){
// If Success type is 1, show success message with type success
$('.top-right').notify({
message: { text: xhr.status + " " + xhr.statusText },
type: 'danger',
}).show();
},
});
})
});
完成此操作后,将使用实际数据重新加载div。
在div内有一个表格,但之后有
$(".tab-content").load(" .tab-content > *"
,
表单提交不再起作用。当我刷新整个页面时,一切正常。
有什么办法可以使div加载()并使表单上的提交按钮再次起作用吗?