开发者

How to pass javascript variable value to java class

开发者 https://www.devze.com 2023-02-16 09:25 出处:网络
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 g

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

精彩评论

暂无评论...
验证码 换一张
取 消