Trouble with JQuery both Functions won't work at the same time

<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">

Okay, Down below is modal I am using so when a user clicks on Delete they are greeted with a warning message. Basically saying are you sure you want to delete this? I use JQuery to get the name of item that will be deleted. After that, I want the user to be able to click on “Delete” and send a link to list-delete.php with the corresponding ID. Both functions work independently of each-other, but not together. Can you look at this and explain to me why.

Thank you.

   <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                            <h4 class="modal-title" id="deleteModalLabel"></h4>
                        </div>
                        <div class="modal-body">
                            <p> Are you sure you want to delete this list? </p>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                            <button type="button" id="deleteModalButton" type="button" class="btn btn-primary">Delete</button>
                        </div>
                    </div>
                </div>
            </div>  
    </div>
<?php
$script = "<script> $( document ).ready(function() {
                
           function loadDeletePage(id) {
          window.location.href = 'list-delete.php?id=' + id;
             }
              
                // Apply click event to all delete buttons
                  var deleteButtons = $(\"[href^='list-delete.php']\" );
                  
                  $(deleteButtons).on('click',function(){
                        
                    // Get list id from delete button
                    var uccId = $(this).attr('href').slice(19);
                    
                    // Use the list id to get list-name 
                    var listNameSelector = ($('#list-name'+uccId));
                    var listName = (listNameSelector).html();
                    
                    // Plug list name into modal 
                    $('#deleteModalLabel').html(listName);
                    
                    // Show modal
                    $('#deleteModal').modal('show');
                    
                   
                         
                   // Listener and passes ID to function to be trigged when the delete button is pressed.
                   $('#deleteModalButton').on('click', loadDeletePage(uccId));
                   });
                     return false; 
             
                    
                    });</script>";
?>

Please format your post. We can not see yoru code. Highlight your code and press the </> button in the reply box so we can see your code.