MediaWiki:Sandbox.js
Revision as of 06:19, 6 August 2019 by Nussnougat (talk | contribs)
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
function drawTable(mobs) { var output = $("#sandbox-output"); var html = "<table><th><td>Name</td><td>HP</td><td>Damage</td></th>"; mobs.forEach(function(mob) { html += "<tr>"; html += "<td><b>"+mob["name"]+"</b></td>"; html += "<td>"+mob["hp"]+"</td>"; html += "<td>"+mob["damage"]+"</td>"; html += "</tr>" }); html += "</table>"; output.html(html); } $(document).ready(function() { $.ajax({ type: "GET", dataType: "json", url: "/vv-api/get-creatures.php", success: function(data) { console.log(data.result); drawTable(data.result); }, error: function(status, exec) { console.log(status); } }); $('#sandbox-output').html('Sandbox JS loaded!'); });