This question about Missing functionality: Answered

server side of AJAX queries

I would like to have my web client do an ajax query (using jQuery, if it matters) that has a couple of arguments. Does FOSWiki provide something on the server side that would support that?

My data are in a table. Simplifying slightly, it has columns A, B, and C. A and B jointly index the table.

I want to ask the server for the C entry on the row for which A=xx and B=yy; there will be at most 1 row satisfying the condition; there might be none.

I've googled and searched this site; there are quite a few entries about AJAX and jQuery, but they seem to concern the client side. Some of the info imagines that I am querying for a page, but I really want data on a page (there are 40 or 50 rows, and the contents of C are relatively small).

I could merge the 2 keys into a single key like "xx-yy" if that would help (my real case has 3 keys).

I am flexible on both the input and output data formatting; the input data are currently a csv dump of a spreadsheet. All the values involved are text.

Thanks.
Ah, what a can of worms.

The simple answer to this question is "no", though that requires a bit more expansion. There is no way to index data in an arbitrary table in an arbitrary topicg. But Foswiki is a very flexible beast, and you have access to just about anything.

Using your example, let's say I have a table in topic Sandbox.XxxYyy as follows:
| *A* | *B* | *C* |
| xx  | yy  | zz |
I can create a topic (say, 'Sandbox.GetC') with a parameterised search in it, thus:
%SEARCH{
 "^\| %URLPARAM{"A"}% \| %URLPARAM{"B"}% \|"
 type="regex"
 multiple="on"
 format="$pattern(.*?\| %URLPARAM{"A"}% \| %URLPARAM{"B"}% \| (.*) \|.*)"
 nonoise="on"}%
I can then view this topic using some parameters that suppress the skin:

http://trunk.foswiki.org/Sandbox/GetC?A=xx;B=yy;content_type=text/plain;skin=none

Obviously this last URL is the query you wanted.

You can be as clever as you want writing the search topics, parameterising as much as you want, or even passing in the entire search expression.

-- CrawfordCurrie - 29 Apr 2010

It looks as if this solution requires creating a separate page for each xx and yy. Am I understanding that correctly? I was hoping for something that would allow me to put the whole table somewhere and then get a row.

Yes, I know that would be a natural thing to do with a database. But our site is hosted by a 3rd party, and so I'm trying to figure out a solution that doesn't require administrative intervention that may not be forthcoming.

-- RossBoylan - 29 Apr 2010

To keep the example simple I created a search page that is specific to your search, but read my last sentence above.

Using in-topic tables to store data, while not exactly a dumb idea, isn't the best way to store data. Generally using a schema defined in a form definition topic and then using a topic to store each row of the table in form fields is a more scalable solution. That approach allows you to use %SEARCH{type="query" which is a more databasey approach. But it depends on what data you are storing, and how you expect users to interact with it.

-- CrawfordCurrie - 30 Apr 2010

QuestionForm edit

Subject Missing functionality
Extension
Version Foswiki 1.0.4
Status Answered
Topic revision: r4 - 30 Apr 2010, CrawfordCurrie
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy