When it comes to calling a method in an applet from JavaScript, I am facing a challenge. Both the applet and the JavaScript code are running on the same webpage. I am aware of how to call applet methods from JavaScript and vice versa using techniques like
MyAppletID.appletMethodName(args)
and JSObject
. However, these approaches only allow one-way communication and do not support the passing of return values from one language to the other.
My goal is to achieve something like this...
var result = 0;
callAppletMethod( JSON.stringify(args), function(r) { result = r; } )
...in order to invoke an applet method and capture the return value in the variable result
.
I am seeking advice on any technique, library, or toolkit that facilitates this type of two-way communication between JavaScript and an applet.
Should I explore the use of a remote procedure call protocol such as JSON-RPC? Or is there a more effective approach available?
(As someone new to JavaScript and web programming, I appreciate any guidance.)