File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes how to get an object reutrned by javascript? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to get an object reutrned by javascript?" Watch "how to get an object reutrned by javascript?" New topic
Author

how to get an object reutrned by javascript?

Manas Saxena
Ranch Hand

Joined: Mar 01, 2013
Posts: 38
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

Joined: Aug 30, 2011
Posts: 24

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



Regards,

Vigneswaran.M
Manas Saxena
Ranch Hand

Joined: Mar 01, 2013
Posts: 38
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get an object reutrned by javascript?
 
Similar Threads
Absolute div dynamically appended to body element
DIV Tag Loading Behavior is Erratic
I want to implement editable autocompleter in struts2 using jquery.
Refererancing Servlet from my JSP
How To Reference a Dynamic DOM Object From JS