JQuery doesn't work after I ctrl click f5 (which refreshes and clears cache in chrome). But the odd thing is that this problem goes away when I add an alert statement at the top of my code.
My jquery is a local file. What's going on here?
Also, all of my code is in
    <script type="text/javascript" src="javascript/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="javascript/main.js"></script>
<script type="text/javascript">
    var json_screenSizes;
    <!-- The function loadJSON is located in main.js (loaded above) -->
    loadJSON("json/screenSizes.json", function (response) {
        // Parse JSON string into object
        json_screenSizes = JSON.parse(response);
    });
    alert('read'); <!-- This causes code below to work on cache refresh */
    /* DOCUMENT READY */
    $(function () {
        var xhr;
        <!-- This on keyup code never calls on cache clearing but does on normal refresh -->
        $(".search_dreams form input[type=search]").on("keyup", function () {
            if (xhr && xhr.readyState != 4) {
                xhr.abort();
            }
            if ($(".search_dreams form input").val().length < 3) { /* If search input is empty */
                $(".search_dreams .results ul").html("");
                $(".search_dreams .results").hide();
                $(".search_dreams input.search").removeClass("orange");
                return;
            }
            xhr = $.ajax({
                type: 'GET',
                url: 'searchDreams.php',
                data: {numResults: 10, keyword: $(".search_dreams form input").val()},
                success: function (data) {
                    data = JSON.parse(data);
                    var output = "";
                    alert("succes");
                    /* ADD DREAM */
                    for (var i in data) {
                        output += "<li class='addDream'>";
                        /* Dream Name */
                        output += "<div class='dream_name'><a href='google.com'>" + data[i].dreamName + "</a></div>";
                        output += "<div class='button_container'><input class='addDream small orange' type='submit' value='Add Dream'></div>";
                        /* Add dream button */
                        output += "</li>";
                    }
                    $(".search_dreams input.search").addClass("orange");
                    $(".search_dreams .results").show();
                    $(".search_dreams .results ul").html(output);
                }
            });
        });
    });
</script>
Except for the alert statement I mentioned adding.
 
     
    