2014-04-05 38 views
0

在我的appjs項目中,我將顯示一個網頁,其中包含以下表單。 當用戶提交此表單時,出現內部服務器錯誤。 你能告訴我如何在我的app.js中處理這個/ submit_pariring_code請求嗎?如何在appjs中提交表單?

我可以處理這個表單提交的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> 
+0

請你讓我知道什麼是行動標籤這一/ submit_pairing_code? – napender

+0

submit_pairing_code會將配對代碼提交給遠程網絡服務器,並驗證其是否正確。 要發送到服務器,我想先在appjs桌面應用程序中接收它,它將向遠程Web服務器發出http請求。 –

+0

[HTML5佔位符屬性不能代替標籤元素](http://www.456bereastreet.com/archive/201204/the_html5_placeholder_attribute_is_not_a_substitute_for_the_label_element/) – Quentin

回答

1

下面的代碼做了魔術。

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); 
});