I've added a SweetAlert into an existing upload Form, where upon selecting the Submit button it successfully displayed the pop-up alert. Like so:

$('#submit-btn').on('click',function(e){
e.preventDefault();
var form = $('.pt_upld_page_frm');
swal.fire({
title: "Are you sure?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, submit it!",
closeOnConfirm: false
}).then((result) => {
if (result.isConfirmed) { $('.pt_upld_page_frm').submit(); }

});
});

But, my goal is to have the "Yes, submit it" to actually submit the chosen uploaded file. But it didn't upload it.
So, I added code from farther down the file, into the alert, like so:

$('#submit-btn').on('click',function(e){
e.preventDefault();
var form = $('.pt_upld_page_frm');
swal.fire({
title: "Are you sure?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, submit it!",
closeOnConfirm: false
}).then((result) => {
if (result.isConfirmed) {
$('.pt_upld_page_frm').ajaxForm({
   //$('#upload-form form').ajaxForm({
      url: '{{LINK aj/ffmpeg-submit}}?hash=' + $('.main_session').val(),
    beforeSend: function() {
       $('#submit-btn').attr('disabled', true);
       $('#submit-btn').val("{{LANG please_wait}}");
},
 success: function(data) {
         if (data.status == 200) {
window.location.href = '{{LINK home}}';
         }
         else if(data.status == 402){
            swal({
               title: '{{LANG error}}',
               text: data.message,
               type: 'error',
               confirmButtonColor: '#3085d6',
               cancelButtonColor: '#d33',
               confirmButtonText: 'OK',
               buttonsStyling: true,
               confirmButtonClass: 'btn btn-success',
            }).then(function(){
               window.location.href = '{{LINK upload-video}}';
            },
            function() {
               window.location.href = '{{LINK }}';
            });
         }
         else {
            $('#submit-btn').attr('disabled', false);
             $('#submit-btn').val('{{LANG publish}}');
            Snackbar.show({text: '<div>'+ data.message +'</div>'});
         }
      }
   });
//});
});
}
});
});

But now it submits successfully, but doesn't display the Alert first. The goal is to have the "Yes, submit it" to actually submit
Any guidance is welcomed.

It would seem there is a problem with a proper closing...a syntax error. There are too many for me to trace, you can try formatting it better in something like notepad++ to see if that helps locate it.

In the following screen, on the far right box, you'll see a red exclamation mark. Click it to see what I mean. It could be a problem with this render but based on the behaviour you describe, it would seem to be something like syntax causing a problem.

https://codepen.io/SolidSolutions/pen/ExpNKmR

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.