I am using the following code to try and get the javascript variable from the session through AJAX but every time I run the action there is nothing coming back in my controller but there is within my IE browser?
$(document).ready(function() {
$(".GN").click(function() {
var gnval = $(this).html();
alert(gnval);
window.location = 'test.action' + gnval;
var value = gnval;
$.ajax({
method: "POST",
url: "test.action",
data: {
gnval: value
}
});
});
});
my Java:
String groupName = request.getParameter("gnval");
HTML:
<div class="GN" data-gnval="yourVal">yourVal</div>
And Javascript:
$(".GN").click(function() {
var yourVal = $(this).data('gnval');
$.ajax({
method: "POST",
url: "test.action", // correct url ?
data: {
gnval: yourVal
}
});
});
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.