开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜