0

在我的 appjs 项目中,我显示了一个网页,其中包含以下表单。当用户提交此表单时,我收到内部服务器错误。你能告诉我如何在我的 app.js 中处理这个 /submit_pariring_code 请求吗?

我可以在 javascript 代码中处理此表单提交,但这将使我在服务器端允许跨域(我不想这样做。)

  <form class="form-signin" action="/submit_pairing_code">
    <h3 class="form-signin-heading">Please enter your Pairing Code</h3>
    <input type="text" name="pairing_code" class="input-block-level" placeholder="Pairing Code">
    <br/>
    <input type="text" name="computer_name" class="input-block-level" placeholder="Your Computer Name">
    <br/>
    <button class="btn btn-large btn-primary" type="submit">Submit</button>
  </form>
4

1 回答 1

1

Following code did the magic.

var app = module.exports = require('appjs');
var http = require('http');

app.serveFilesFrom(__dirname + '/content');

app.router.get('/submit_pairing_code', function(request, response, next){
  response.send('Here is your pairing_code ' + request.params.pairing_code);
});
于 2014-04-05T16:08:46.370 回答