The aim of this gist is to show how to handle the execution of simple SPARQL query over the DBpedia SPARQL endpoint using Javascript, JQuery and AJAX.
The difference between this gist and the previous gists [1] [2] is the handling of multiple table fields.
xxxxxxxxxx
<html>
<head>
<meta name="description" content="Seminario LOD CNR MI - Example 3" />
<meta charset="utf-8">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="index.js"></script>
<title>Seminario Linked Data</title>
</head>
<body>
<h1>EXAMPLE N° 3</h1>
<div><b>SPARQL QUERY:</b></div>
<div id="query" contentEditable="true">
<pre>
<code>
PREFIX : <https://dbpedia.org/resource/>
PREFIX dbp: <https://dbpedia.org/ontology/>
PREFIX rdf: <https://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dbpprop: <https://dbpedia.org/property/>
SELECT ?town ?province ?population ?area ?mayor
WHERE {
?town dbp:country :Italy;
dbp:region :Tuscany;
dbp:province ?province;
dbp:populationTotal ?population;
dbp:areaTotal ?area;
dbpprop:mayor ?mayor.
}
</code>
</pre>
</div>
<div>
<input type="button" onclick="retrieveData()" value="Execute Query">
</div>
<br>
<div><b>RESULTS:</b></div><br>
<div id="output_div">
</div>
</body>
</html>
https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js