-
-
Save DLzer/90dcee77df2f795b48d12d33fe6c7ed7 to your computer and use it in GitHub Desktop.
External API to HTML via AJAX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<!-- Your List --> | |
<ul id="myList"> | |
</ul> | |
</div> | |
<script> | |
// List jQuery variable | |
$list = $('#myList'); | |
// AJAX Call using GET | |
$.ajax({ | |
type: "GET", | |
url: "example.com", | |
success: function(resp) { | |
// If the call was successful, loop through the resp.data array | |
for(var i = 0; i < resp.data.length; i++) { | |
// for each index existing in resp.data, append the value as a list item to your list. | |
$list.append('<li>'+resp.data[i]+'</li>'); | |
} | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment