访问 Node.JS 中的 Jade table 值
Access Jade table values in Node.JS
table(class= "table-striped table-striped table-hover")
thead
th
h2 #{movie.title}
tbody
tr
td
b Tagline : #{movie.tag}
br
b Rating : #{movie.rating}
br
b Synopsis :
p #{movie.overview}
b Available Copies : #{movie.copies}
br
input.btn-danger.btn-sm(type="submit", value="Buy")
td
img(src= movie.poster width="250" height="300")
p
a.btn.btn-info(href='http://www.imdb.com/title/'+movie.movie_id) Watch Trailer »
#{ }
值来自 Mysql table.提交此页面后,我想重新使用 #{movie.title}
#{movie.tag}
在 Node.js 控制台中。例如,我想做 console.log(movie.title)
我该怎么做?任何帮助将不胜感激。
This might not be an efficient way.Tried using global
object.
global.movieName = rows[0].title;
global.movieRating = rows[0].rating;
提交 jquery,然后将 #{movie.title}
和 #{movie.tag}
添加到 post 的变量中,有点像这样..
按钮:
<input type='button' value='Submit form' onClick='submitDetailsForm()' />
JS:
<script language="javascript" type="text/javascript">
var title = !{
JSON.stringify(movie.title)
};
var tag = !{
JSON.stringify(movie.tag)
};
var data = {
title: title,
tag: tag
};
function submitDetailsForm() {
$.ajax({
type: 'POST',
data: JSON.stringify(data),
cache: false,
contentType: 'application/json',
url: '/send',
success: function(retorno) {
}
});
}
</script>
Node.js:
app.post('/send', function(req, res) {
console.log(req.title);
console.log(req.tag);
});
table(class= "table-striped table-striped table-hover")
thead
th
h2 #{movie.title}
tbody
tr
td
b Tagline : #{movie.tag}
br
b Rating : #{movie.rating}
br
b Synopsis :
p #{movie.overview}
b Available Copies : #{movie.copies}
br
input.btn-danger.btn-sm(type="submit", value="Buy")
td
img(src= movie.poster width="250" height="300")
p
a.btn.btn-info(href='http://www.imdb.com/title/'+movie.movie_id) Watch Trailer »
#{ }
值来自 Mysql table.提交此页面后,我想重新使用 #{movie.title}
#{movie.tag}
在 Node.js 控制台中。例如,我想做 console.log(movie.title)
我该怎么做?任何帮助将不胜感激。
This might not be an efficient way.Tried using
global
object.
global.movieName = rows[0].title;
global.movieRating = rows[0].rating;
提交 jquery,然后将 #{movie.title}
和 #{movie.tag}
添加到 post 的变量中,有点像这样..
按钮:
<input type='button' value='Submit form' onClick='submitDetailsForm()' />
JS:
<script language="javascript" type="text/javascript">
var title = !{
JSON.stringify(movie.title)
};
var tag = !{
JSON.stringify(movie.tag)
};
var data = {
title: title,
tag: tag
};
function submitDetailsForm() {
$.ajax({
type: 'POST',
data: JSON.stringify(data),
cache: false,
contentType: 'application/json',
url: '/send',
success: function(retorno) {
}
});
}
</script>
Node.js:
app.post('/send', function(req, res) {
console.log(req.title);
console.log(req.tag);
});