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 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 );
}
});
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.