Welcome Guest, Not a member yet? Register   Sign In
[Solved] Stop boostrap modal from closing if form validtion false.
#2

I have had to use json now for event posting and have got it working for what I need

PHP Code:
<script type="text/javascript">
$(
document).ready(function() {
$(
'#submit').on('click', function(e) {

    
e.preventDefault();

    $.
ajax({
        
        
url'dashboard/calendar_modal/add_new_event',
        
type'post',
        
dataType'json',
        
data: new FormData($('#form-calendar')[0]),
        
cachefalse,
        
contentTypefalse,
        
processDatafalse,
        
        
beforeSend: function() {
            $(
'#button-upload i').replaceWith('<i class="fa fa-circle-o-notch fa-spin"></i>');
            $(
'#button-upload').prop('disabled'true);
        },

        
complete: function() {
            $(
'#button-upload i').replaceWith('<i class="fa fa-upload"></i>');
            $(
'#button-upload').prop('disabled'false);
        },
        
        
success: function(json) {
            if (
json['error']) {

                
alert(json['error']);
            }

            if (
json['success']) {

                
alert(json['success']);

                $(
"#modal-calendar").modal('hide');

                
window.location.reload(true);

            }
        },
            
        
error: function(xhrajaxOptionsthrownError) {
            
alert(thrownError "\r\n" xhr.statusText "\r\n" xhr.responseText);
        }

    });

});
});
</
script
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
RE: Stop boostrap modal from closing if form validtion false. - by wolfgang1983 - 01-04-2016, 04:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB