Example Ajax Get Request (No Auth)

by dshilkret

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $.ajax({url: "https://api.openweathermap.org/data/2.5/weather?zip=94040,us&appid=d92b1b6e4dbe815fad4069479bddd37b",type:"GET",beforeSend: function(xhr){xhr.setRequestHeader('Accept', 'application/json');}, success: function(result){
        var json_text = JSON.stringify(result);
           $("#div1").html(result.name);
           
        }});
    });
});
</script>

<body>

<div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div>

<button>Get External Content</button>

</body>