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?
//--- server code ---
import vibe.d, std.stdio;
void handleRequest(HttpServerRequest req, HttpServerResponse res)
{
res.redirect("/index.html");
}
void report(HttpServerRequest req, HttpServerResponse res) {
writeln(req.params); // prints: [ ]
}
static this() {
auto settings = new HttpServerSettings;
settings.port = 8080;
auto router = new UrlRouter;
router.get("/", &handleRequest);
router.get("*", serveStaticFiles("./public/"));
router.get("/report", &report);
listenHttp(settings, router);
}
//--- js snippet inside the hosted HTML page ---
$.ajax({
url: 'http://localhost:8080/report',
data: 'test=42'
});
Thanks,
Josh