Am 11.09.2012 06:04, schrieb Joshua Niehus:
(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
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 .
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.
a kind of middleware, that could add something to params so that later
stages have that information available: