'Why isnt my jQuery/Javascript working?

Trying to learn some basic javascript and api usage. Trying to get some weather information from Open Weather Map but none of the alert or console.log requests are being reported by the browser (Chrome).

    <script type="text/javascript" src="jquery-3.2.1.min.js">
    alert("this works first maybe");
    console.log("HEEEELLLLOOOOO");
        $(document).ready(function(){
            var i = 0;
            getJson();

            function getJson() {
                    console.log("getting data now");
                    $.getJSON("openweatherlink");
            }
        });
    </script>


Solution 1:[1]

You can not use src in a <script> that contains code.

Use

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
    Your code
</script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
  alert("this works first maybe");
  console.log("HEEEELLLLOOOOO");
  $(document).ready(function() {
    var i = 0;
    getJson();

    function getJson() {
      console.log("getting data now");
      $.getJSON("openweatherlink");
    }
  });
</script>

Solution 2:[2]

You code should be like below.

First script tag should contain jQuery import statement.

Second script tag in which you can write jQuery/javascript code.

<script src="jquery-1.x-git.min.js" type="text/javascript"></script>
<script>
    alert("this works first maybe");
    console.log("HEEEELLLLOOOOO");
    $(document).ready(function () {
        var i = 0;
        getJson();

        function getJson() {
            console.log("getting data now");
            $.getJSON("openweatherlink");
        }
    });
</script>

Solution 3:[3]

<script type="text/javascript" src="jquery-3.2.1.min.js">
<script>
    $(document).ready(function(){
        alert("this works first maybe");
        console.log("HEEEELLLLOOOOO");
        var i = 0;
        getJson();
    });
    function getJson() {
         console.log("getting data now");
          $.getJSON("openweatherlink");
    }
</script>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 TechnoCrat
Solution 3 Shravan Goswami