Dear Godmar,
Sorry if my recent reply was misleading there is no explicit support for jsonp at the moment but to build it yourself (pad the result with the help of xquery).
I guess it could be added in case s/o wants to do it :-)
Michael On 21.10.2011, at 23:23, Godmar Back godmar@gmail.com wrote:
Supporting JSON-P would be great; Michael mentioned that BaseX supports it, but a search for JSON-P or 'callback' in the Wiki turns up empty...
What's the callback argument used in JSON-P called? callback?
- Godmar
On Fri, Oct 21, 2011 at 12:51 AM, colin mcenearney colinmcenearney@yahoo.com wrote:
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:
- 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)
- 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
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk