Am 11.09.2012 18:11, schrieb simendsjo:

On Tuesday, 11 September 2012 at 06:51:26 UTC, Sönke Ludwig wrote:

Am 11.09.2012 06:04, schrieb Joshua Niehus:

Hello,

(entry level question ahead)

I have a simple static html page that will generate a piece of data that
I would like send back to the server. But when I try to get the params
from the request im getting an empty array. Is the following server
side code correct for this sort of thing?

The total set of parameters is currently split up into four subsets:

query: fields in the query string of the URL
form: fields of a POSTed HTML form, if any
(application/x-www-form-urlencoded)
params: custom parameters added to the request by the server/user
json: parsed JSON of the request, if any (application/json)

The params map is used for example by the UrlRouter to put in any
matched variables in the URL (e.g. /:id/view would produce a param
'id'). You could also use this for example to store authentication
information for later processing [1].

In your example you probably also want to set the "Content-Type" header
of the ajax request to "application/x-www-form-urlencoded". In that case
the 'form' map would contain ["test": "42"].

Another alternative is to set "Content-Type" to "application/json" and
use the 'json' field to get the contents.

Regards,
Sönke

[1]: The authentication example shows how performBasicAuth() is added as
a kind of middleware, that could add something to params so that later
stages have that information available:
http://www.vibed.org/docs#http-authentication

Could you start adding these nice answers to the documentation or at
least the blog. this group doesn't have many members, and answers such
as this deserves more readers.

As soon as I have time... right now there is still too much stuff with a
higher priority (mostly non-vibe.d related).