Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access javascript variable in java without submitting form

 
Sonal Jogi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have to access a javascript variable in java but without submitting the form. Is there any way to do it?
For e.g. i have a function
function google_ad_request_done(google_ads) {

if (google_ads.length < 1 )
return;

//some other working
}
I have to know the length of google_ads array. Any help would be appreciated.

Thanks in advance,
sonal
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can look into Ajax to post data back.

Seach google for Ajax JavaScript
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or search for "XMLHttpRequest" (same technology) which allows you to make a "behind the scenes" request to the server without refreshing the containing page.
 
Sonal Jogi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for the prompt reply. But the thing is, I am making the request to an external server (google) and, It in turn is calling the function I had defined, and returns the google_ad array. AJAX requies server side programming also which i cannot do, cause server is outside my scope.

Could you please suggest some other alternative.

Thanks & regards,
sonal
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You use the XMLHttpRequest back to your server which does the request to google's server.

If you can not do that then it sounds like you are out of luck.

Eric
 
Sonal Jogi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,

It does seem like that.

Anyways, Thanks a lot!!

Regards,
sonal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic