Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get an object reutrned by javascript?

 
Manas Saxena
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am making a social networking website where in i am adding the functionality of letting people being tagged in photos.For this i have to store the co-ordinates of the tag window and send them to servlet so that i can store them in a databse.
However the code which i have ,stores the co-ordinates in javascript function.(Heres the javascript code):


Now how do i get the variables pos_x,pos_y,pos_width,pos_height and send them to a servlet.


Heres one approach which i applied:I created an object and stored the co-ordinates inthat object in the above javascript code like this:


However i do not know how to get the returned object (namely "coordinates")in my html calling code.Hers how i call the above javascript function:
<input type='button' value='Add Tag' onclick='return addTag()' />

Please suggest me an approach or help me correct my approach.
 
Vigneswaran Marimuthu
Greenhorn
Posts: 24
Eclipse IDE Oracle Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you are planning to do is to send the values (coordinate object) to the servlet on click of the button using ajax.

So change the



to

 
Manas Saxena
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi thanks for the reply.Though i found another work around .
I sent the parameters in the javascript function to the servlet via ajax call.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic