I have this selectBox:
<select class="span2" name="filterYear" id="filterYear" style="margin-right:10px;">
<% for (var i = 0; i < years.length; i++) { %>
<% if (years[i] == selectedYear) { %>
<option value="<%= years[i] %>" selected="selected"><%= years[i] %></option>
<% } else { %>
<option value="<%= years[i] %>"><%= years[i] %></option>
<% } %>
<% } %>
</select>
With this js function:
$("#filterYear").change(function(e){
$.ajax({
url: '/changeYear/' + this.value,
type: 'GET'
});
}
});
And this is the node.js function. I get the value of the selectBox and set it to another variable:
exports.changeYear = function (req, res) {
var year = req.param('year');
req.session.maindashSelectedYear = year;
};
The problem is this: If a user doesn't click the selectBox, the function req.param('year')
does not work... But if a user does click it, everything works fine! I have no idea how to resolve this.
您可以像这样从网址获取参数
req.params.years
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.