Reputation: 418
can we get variable from ajax as request.getparameter in Servlet?
Upvotes: 2
Views: 2397
Reputation: 109
you can use it.
Use query parameter.
function action(arg0) {
$.ajax({
url: '/test',
type: 'get' // 'get' or 'post'
data: 'arg0=' + arg0, //variable you want to send.
success: function(result) {
console.log(result);
}
}); }
in Servlet
request.getParameter("arg0")
Upvotes: 1
Reputation: 5868
Yes but make sure you pass the name of the parameter the same as which you use in ajax data.
Upvotes: 0