Dear Bob,
in this example please find:
function initControl () {
$("#btn-getmol").on("click", function (e) {
marvinSketcherInstance.exportStructure("mrv").then(function(source) {
$("#molsource").text(source);
}, function(error) {
alert("Molecule export failed:"+error);
});
});
}
The short answer is that in this example the source object is what you need,
Let's see what it does line by line:
1: The initControl function will...
2: Add a click handler to the button with "btn-getmol" id.which will
3: TRY to EXPORT the current structure in "mrv", AND IF the export is SUCCESSFUL, there will be a function with the source parameter...
4: ...and we pass this source text to a textarea witth "molsource" id..
5: BUT IF the EXPORT FAILS, there will be another function with error parameter
6: And the user will be notified through an alert popup cintaining the error message.
___________________________________________________________________________________________
This example might seem to be a little difficult, but it is based on the concept of the promise, which is a widely accepted technology in "js world". And since export happens in the server side, (eg: export in smiles, export a reaction in mrv, rgfile export etc.) the asynchronous process may fail because of different reasons. So there is a way to handle the successfull export as well as the failing one.
In Marvin JS examples jquery is used, so some of those expressions are not available in pure javascript. Certainly there is a way to do the same in pure javascript.
I encourage you to look up our examples, because they are updated release by release, and there is at least one usecase for all our methods in the API.