  <div id="askquestion" class="modal modal-fixed-footer">
    <div class="modal-content">
      <h4>Ask A Question</h4>
      <?php require_once 'includes/components/post-form.php'; ?>
    </div>
    <div class="modal-footer">
      <a id="submitQuestion" class="waves-effect waves-green btn-flat ">send question</a>
      <a href="#" class="modal-action modal-close waves-effect waves-green btn-flat ">Cancel</a>
    </div>
  </div>
  <?php require_once "components/actual-footer.php" ?>
             
    <script src="assets/js/jquery-3.2.1.js"></script>
    <script src="assets/js/materialize.min.js"></script>
    <script>
        $(".button-collapse").sideNav();
        $('ul.tabs').tabs();
        $('select').material_select();
        $('.modal').modal();
        $('.collapsible').collapsible();

        let submitQuestion = $('#submitQuestion');
        let formField = $('#questionForm');

        submitQuestion.click( function() {
          let error = $('#error');
          let topic = $('#title').val();
          let question = $('#question').val();
          $(this).html('<img src="assets/images/ajax-loading.gif" alt="ajax-loading" width="20px" />');
          
          if(topic === ''){
            error.html('Please provide a topic.');
            $(this).html('Send Question');
          }else if(question === ''){
            error.html('Please provide a question.');
            $(this).html('Send Question');
          }else{
            $.post('includes/server/post-question.php', formField.serialize(), function(data) {
                if(data === 'successful'){
                $(this).html('Send Question');
                  location.reload();
                }else{
                  error.html('Sorry we have a issue and we are working on it.');
                  $(this).html('Send Question');
                }
            });
          }
        });

        $("[id^='editForm_']").slideUp();

        $('body').on('click', '#edit_button', function(e){
            e.preventDefault();
            let id = $(this).attr('edit-btn');
            let editForm = $('#editForm_' + id);
            editForm.slideToggle();
        });

    </script>
</body>
</html>