I'm new to working with SPARQL queries in JavaScript and I need some guidance on how to send these queries to FUSEKI. I am having trouble figuring out if this is even possible and, if it is, what the correct method is.
Currently, I am attempting to use XMLHttpRequest() to send the queries, but I suspect that the query format may be incorrect. I feel quite lost at the moment and would appreciate any help or examples of how to properly send my queries.
So far, I have been encountering errors like:
"INFO [145] 400 SPARQL Update: No 'update=' parameter (1 ms)" "INFO [140] 415 Must be application/sparql-update or application/x-www-form-urlencoded (got text/plain)"
Below is a snippet of the code I have been experimenting with:
var testQuery = 'SELECT * WHERE{?timer <http://schema.org/title> ?title}';
var url = "http://localhost:3030/ds/query";
// var url = "http://localhost:3030/ds/update";
var params = "testQuery";
var http = new XMLHttpRequest();
http.open("POST", url+"?"+params, true);
http.onreadystatechange = function()
{
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send();