Hi Christian and Michael, and everyone.

Thanks for your replies.

I'm still having a little difficulty. Attempting to return results with method=jsonml I still get this error (using jquery's ajax methods):

thrown error: [Exception... "Access to restricted URI denied" code: "1012"

which I think is a result of sending an http-request across different ports.

I think my question might be clearer with some background:  My idea for a simple app to learn the db is a blog, where each entry has its own xml file which contains, among other things, chunks of valid xhtml. I was envisioning a very simple interaction where javascript sends a get or post request and the db returns bits of xhtml.

Can this be done without the use of additional server-side scripting? Maybe with direct calls to an xquery file like http://mysite.com/blog/blog.xq?categ=xmldb&level=beginner ?


Colin


From: Christian Grün <christian.gruen@gmail.com>
To: colin mcenearney <colinmcenearney@yahoo.com>
Cc: "basex-talk@mailman.uni-konstanz.de" <basex-talk@mailman.uni-konstanz.de>
Sent: Tuesday, October 18, 2011 11:54 AM
Subject: Re: [basex-talk] ajax and http server - cross-domain, jsonp or proxy?

Dear Colin,

thanks for your e-mail.

> I'm not really a developer so this might be an obvious question: using
> basex's http server, what is the best strategy for ajax-style communication
> between browser and db?

As Michael already pointed out, there is no "unique" strategy how to
use BaseX with AJAX. One popular way is to use our new "json"
serialization method, which allows you to directly return JSON from
BaseX. A small example:

1. Start the HTTP server via "basexhttp -l" (the -l flag will
communicate with the local database context; this way, no other socket
connection will be used)

2. Via REST, retrieve a document or run a query and specify "jsonml"
as output method:
http://localhost:8984/rest/database/doc.xml?method=jsonml

This way, the XML result will be directly serialized, using the JSONML
syntax. If you have created your XML documents from JSON input files,
you may as well use "json" as serialization format. Pleave check out
our documentation as well:

  http://docs.basex.org/wiki/JSON_Functions

Feel free to ask if this is not exactly what you are looking for.
Christian