There is a function in my code that retrieves JSON text from a specific website:
window.onload = function httpGet()
{
var xmlHttp = null;
var box = document.getElementById("http") //just for testing
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", "http://link_to_Json_Text", false );
xmlHttp.send( null );
box.value += xmlHttp.responseText; //just for testing
return xmlHttp.responseText.toJSON();
}
This will show the results as:
{
"head": {
"vars": [ "uri" , "label" ]
} ,
"results": {
"bindings": [
{
"uri": { "type": "uri" , "value": "http://tematres.befdata.biow.uni-leipzig.de/vocab/?tema=751" } ,
"label": { "type": "literal" , "xml:lang": "en" , "value": "15n" }
} ,
{
Then I utilize this function to extract the values of the JSON as an object:
var results = httpGet().results.bindings.map(function(el){
return { uri: el.uri.value, label: el.label.value };
});
Subsequently, I aim to populate an HTML select menu with the values obtained from the second function.
Nevertheless, there seems to be an issue regarding the correct calling of the second method from the first one, as the console displays errors like :
Uncaught ReferenceError: httpGet is not defined
The goal is to make use of the value
from label
in order to populate the select menu.