jQuery.get() method doesn't work

I'm trying to perform a xquery and get its result, with the following code:

$.get('http://localhost:8984/rest/lod?query=/*:teiCorpus//*:TEI',
    function(data) { 
        alert(data); 
    });

I was expecting a xml response, but so far I don't get a thing. Firebug display the following error:

XML Parsing Error: no element found Location: moz-nullprincipal:{a9dddfb7-5488-424b-8ab1-76913e889282} Line Number 1, Column 1: ^

I don't understand what I'm doing wrong. Any ideas?

EDIT: When I place:

http://localhost:8984/rest/lod?query=/*:teiCorpus//*:TEI

in my address bar, I get

<TEI xmlns="http://www.tei-c.org/ns/1.0" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:svg="http://www.w3.org/2000/svg">
    <teiHeader type="text" xml:id="Fr1">teiHeader</teiHeader>
    <text>teiText</text>
</TEI>

and that's exactly what I need to retrieve with the get.

Upvotes: 1

Views: 319

Answers (1)

m.t.bennett
m.t.bennett

Reputation: 1320

It looks like your URL has some illegal characters, try this

$.get('http://localhost:8984/rest/lod',{ query: '/*:teiCorpus//*:TEI' },

    function(data) { 
        alert(data); 
    });

putting it in as the data parameter will hopefully escape the illegal characters

EDIT:

Looking into your problem more - there could be 2 more things it could be:

1 ) Your trying to do a cross domain request - this is not allowed with XML (you can determine this by looking at the URL in your browser, if it's not the same as http://localhost:8984 its cross-domain)

2 ) Your xml response you are returning is incorrect

Upvotes: 2

Related Questions