How to pass javascript variable value to java class
I want to submit data from a html page to java class. I am using javascript to get data from html page, now I want to send this data to java class to save this data to db. I am using ftl template to generate html so I cant use 开发者_StackOverflow社区jsp here. Please give an example using either javascript of ajax or jquery.
thanks.
You can use jquery to send an ajax request to your Java servlet.
$.ajax({
type: "POST",
url: "/app/servlet/",
data: {name : "John", location : "Boston"},
success: function(msg){
alert( "Data Saved: " + msg );
}
});
精彩评论