上添加值JavaScript是服务器端,你将不得不通过AJAX的变量传递给服务器。
进行ajax请求的最简单方法(个人意见)是使用jQuery库。
这是如何的jQuery做一个Ajax请求:
$(function() {
$.ajax({
method: "POST"
,data: {
sessionVariable: variable
}
,url: //enter the url of your controller/action which the session variable is being sent to, and handled by the server.
,success: function(returnedData){
alert("Session successfully sent to the server");
// you could return something from the controller with more info and display this using the returnedData object.
}
,error: function(){
alert("something went wrong");
}
});
})
更多信息ňjQuery的AJAX请点击此链接>http://api.jquery.com/jquery.ajax/
'Session'是服务器端。 Javascript是客户端。您需要将值传递给服务器(例如使用ajax)并将其设置在控制器 –
好。我真的不知道如何使用Ajax。你能给我更具体的方向吗?谢谢 – Anonymous
然后时间让你做一些研究:) –