0

I have this very weird issue with javascript not being rendered (its just shown as plain text above the body) when I click a link while having history.js running.

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
    $(document).ready(function()
    {
        $("#login_btn").click(function(e) 
        {
            e.preventDefault();

            $.ajax({
                url: document.location.origin + "/index.php/login",
                type: 'POST',
                ContentType: 'application/json',
                data: {'username': $("#login-username").val(), 'password': $("#login-password").val()}
            }).done(function(response){
                if(response == "1") {
                    window.History.pushState({urlPath:'/'},"",'/');
                } else { 
                    $("#login-form").find(".uk-alert-danger:first").hide();
                    $("#login-form").prepend("<div class='uk-alert uk-alert-danger'>Invalid credentials specified.</div>");
                }
            });
        });
    });
</script>

<!-- jQuery -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<!-- jQuery ScrollTo Plugin -->
<script src="//balupton.github.io/jquery-scrollto/lib/jquery-scrollto.js"></script>

<!-- History.js -->
<script src="//browserstate.github.io/history.js/scripts/bundled/html4+html5/jquery.history.js"></script>

<!-- Ajaxify -->
<script src="//rawgithub.com/browserstate/ajaxify/master/ajaxify-html5.js"></script>

History and all that works like it should, but it's just the fact that other JS isn't rendered when using it.

P. Nick
  • 955
  • 1
  • 12
  • 33

1 Answers1

0

Really weird, but it starts working if I include all javascript through PHP, so they get placed above the html tags.

P. Nick
  • 955
  • 1
  • 12
  • 33