LinkedDataFragments / Client.js

[DEPRECATED] A JavaScript client for Triple Pattern Fragments interfaces.
http://linkeddatafragments.org/
Other
92 stars 35 forks source link

[browser version] jQuery.ajax(...).success is not a function #18

Closed pieroit closed 8 years ago

pieroit commented 8 years ago

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:

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:

image

What do you think is happening?

pieroit commented 8 years ago

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 :|

RubenVerborgh commented 8 years ago

Hi @pieroit, thanks for reporting!

jQuery 3.x changed its Promise interface to be standards-compliant. I fixed compatibility in 4dc3e19df97b6a64d5f61681bb5ae7c21839a7d4 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 6928edd336064b2f75f7343c522ffbe1b0ab1b30.