[browser version] jQuery.ajax(...).success is not a function
pieroit opened this issue · comments
Hello,
first of all kudos for the LDF project. I totally agree on the necessity of a smart client with triplestores providing data and not running SPARQL queries.
I'm trying the LDF-client browser version. Built following this instructions:
npm install ldf-client
- enter the
node_modules/ldf-client
folder and runnpm install
andnpm run browserify
- loaded the file
ldf-client-browser.js
on page with a<script>
tag.
The ldf
object is correctly loaded and I try the following:
$(document).ready(function(){
fragmentsClient = new ldf.FragmentsClient('http://fragments.dbpedia.org/2014/en');
var query = 'SELECT * { ?s ?p ?o . } LIMIT 100',
results = new ldf.SparqlIterator(query, { fragmentsClient: fragmentsClient });
results.on('data', console.log);
});
Result:
What do you think is happening?
Resolved by using the same jQuery version used here, via npm install jquery@2.1.0
.
Another note which may be useful for the docs, this will not print results in the console on Chrome:
results.on('data', console.log);
This will:
results.on('data', function(d){
console.log(d);
});
I don't know why, I guess the callback must not be a nested function :|
Hi @pieroit, thanks for reporting!
jQuery 3.x changed its Promise interface to be standards-compliant. I fixed compatibility in 4dc3e19 some time ago, but this commit is still in the develop branch, due to be released soon. As you mention, using jQuery 2.x also works.
You're right about results.on('data', console.log);
not working in some environments. This is because in Node.js, the log
method is a function independent of the console
object, whereas in Chrome, it is a member function of console
. I have updated the README in 6928edd.