Created
December 1, 2015 11:59
-
-
Save frogcat/545d0cb798f79a707ca4 to your computer and use it in GitHub Desktop.
SPARQL Endpoint に AJAX でアクセスする方法 ref: http://qiita.com/frogcat/items/beb8888bb334699e21ed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://ja.dbpedia.org/sparql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var endpoint = "http://ja.dbpedia.org/sparql"; | |
var query = "select (count(*) as ?count) where {?s ?p ?o.}"; | |
var x = new XMLHttpRequest(); | |
x.onreadystatechange = function() { | |
if (x.readyState == 4 && x.status == 200) | |
document.body.appendChild(document.createTextNode(x.responseText)); | |
}; | |
x.open("GET", endpoint + "?query=" + encodeURIComponent(query), true); | |
x.setRequestHeader("Accept", "application/sparql-results+json"); | |
x.send(); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var endpoint = "http://ja.dbpedia.org/sparql"; | |
var query = "select (count(*) as ?count) where {?s ?p ?o.}"; | |
var x = new XMLHttpRequest(); | |
x.onreadystatechange = function() { | |
if (x.readyState == 4 && x.status == 200) | |
document.body.appendChild(document.createTextNode(x.responseText)); | |
}; | |
x.open("POST", endpoint, true); | |
x.setRequestHeader("Accept", "application/sparql-results+json"); | |
x.setRequestHeader("Content-Type", "application/sparql-query"); | |
x.send(query); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var endpoint = "http://ja.dbpedia.org/sparql"; | |
var query = "select (count(*) as ?count) where {?s ?p ?o.}"; | |
var x = new XMLHttpRequest(); | |
x.onreadystatechange = function() { | |
if (x.readyState == 4 && x.status == 200) | |
document.body.appendChild(document.createTextNode(x.responseText)); | |
}; | |
x.open("POST", endpoint, true); | |
x.setRequestHeader("Accept", "application/sparql-results+json"); | |
x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); | |
x.send("query=" + encodeURIComponent(query)); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select (count(*) as ?count) where {?s ?p ?o.} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment