Skip to content

Instantly share code, notes, and snippets.

@gutierri
Created December 2, 2017 16:53
Show Gist options
  • Save gutierri/200e9a8d18c22fda6b1ef8f5d74ce321 to your computer and use it in GitHub Desktop.
Save gutierri/200e9a8d18c22fda6b1ef8f5d74ce321 to your computer and use it in GitHub Desktop.
for .. of .. obj
$(document).ready(function() {
let print_selectors = [
{selector: '.graphs_alfa', url: 'https://httpbin.org/uuid'},
{selector: '.graphs_beta', url: 'https://httpbin.org/uuid'},
{selector: '.graphs_gama', url: 'https://httpbin.org/uuid'}
];
for (let _obj_print_selectors of print_selectors) {
$.ajax({
url: _obj_print_selectors.url,
success: function(data) {
$(_obj_print_selectors.selector).html(data.uuid)
}
})
}
});
<!DOCTYPE html>
<html>
<head>
<title>Alfa, Beta, Gama</title>
<meta charset="utf-8">
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="html_dom_writter_ajax.js"></script>
</head>
<body>
<div class="graphs_alfa"></div>
<div class="graphs_beta"></div>
<div class="graphs_gama"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment