简体   繁体   中英

How to pass a javascript variable on a jsp to a servlet

I am using google visualization API java wrapper to create a reporting module. I am using image charts.

Now I want to pass the url of the generated chart to a servelet. I can get the url of the generated graph using getImageUrl() method. I have stored the value of that url in a javascript variable.

How can I pass the URL through ajax?

Pass it as one of the parameters in $.ajax(); or $.post(); if you are using jquery. just as you would pass any other data in an Ajax call. An example would be:

$.ajax({
  type: "POST",
  url: urlToCall,
  data: { 'param': valueOfParam },

});

Pass it as param is passed above.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM