0
我一直在使用快遞JS \如何發送數組值到HTML頁面中明確JS
的NodeJSvar express= require("express");
var path= require("path");
var app= express();
app.use(express.static(__dirname));
var users=[ { userName: "faizan", password: "faizan", email: "[email protected]"},
{ userName: "ali", password: "ali", email: "[email protected]"},
{ userName: "hussain", password: "hussain", email: "[email protected]"},
{ userName: "hassan", password: "hassan", email: "[email protected]"},
];
app.get('/',function(request , response){
response.sendFile(__dirname+ '/index.html');
});
app.get('/frmSignUp', function(request, response){
users.push({
userName: request.query["userName"],
password: request.query["password"],
email: request.query["email"]
});
response.sendFile(__dirname+ '/dashboard.html');
//how can i show my user array items in my dashboard html page?? Question1
});
app.get('/frmSignIn',function(request, response)
{
if(users.contains(request.query["userName"])) //this is invalid
// is there any way available to check userName in array that is this exists?
response.sendFile(__dirname+ '/dashboard.html');
})
var server =app.listen(3010, function(){
console.log("server running on port "+ server.address().port);
})
我在根目錄下指數註冊簽到和Dashboard HTML頁面這個簡單的app.js。我有問題,在上面的代碼中評論,請讓我知道這些東西可能對我來說?
你能定義第一部分的答案嗎! – 2014-11-01 15:40:07
我已經用示例更新了我的答案。 – mscdex 2014-11-01 18:47:26
非常感謝你,但一個修改要求是在根目錄(命名視圖)中創建一個文件夾並將dashboard.js放在那裏 – 2014-11-02 05:38:34