originally posted in:BungieNetPlatform
Does anyone have any sample javascript for this? I'm trying to get it to work but so far my results are simply errors.
English
-
Ah, unfortunately requests from JavaScript hosted by another web site are not currently supported. You will want to create your own server-side proxy for our services and call through that service.
-
Hello VThornheart, Many thanks. I removed the file from my server and loaded the script from Chromium and it works. Here is the source and a partial result. [quote]<!DOCTYPE html> <html> <body> <div id="id01"></div> <script> var xmlhttp = new XMLHttpRequest(); var url = "https://www.bungie.net/platform/destiny/vanguard/grimoire/2/4611686018437163478/"; xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { var myArr = JSON.parse(xmlhttp.responseText); myFunction(myArr); } } xmlhttp.open("GET", url, true); xmlhttp.setRequestHeader("X-API-Key","...my code here...."); xmlhttp.send(); function myFunction(arr) { var out = ""; var i; var len = arr.Response.data.bonuses.length; for(i = 0; i < len; i++) { out += '<p> Card: ' + arr.Response.data.bonuses[i].cardName + '</p>' + '<p> Bonus: ' + arr.Response.data.bonuses[i].bonusDescription + '</p>' + '<p> Progress: ' + '['+ arr.Response.data.bonuses[i].statName + '] ' + arr.Response.data.bonuses[i].value + '/' + arr.Response.data.bonuses[i].threshold + '</p>' + '<br>'; } document.getElementById("id01").innerHTML = out; } </script> </body> </html> [/quote] And the Result: [quote]Card: Vandal Bonus: All characters earn more Glimmer when this combatant is killed with a Glimmer-drop consumable active. Progress: [Kills] 9450/750 Card: Dreg Bonus: All characters earn more Glimmer when this combatant is killed with a Glimmer-drop consumable active. Progress: [Kills] 11789/1000 Card: Shank Bonus: All characters earn more Glimmer when this combatant is killed with a Glimmer-drop consumable active. Progress: [Kills] 4190/375 Card: Old Russia Bonus: Extra materials drop from material nodes in this destination. Progress: [Kills] 26821/2500 [/quote]
-
Woot!