I’d like to pass an associative array (or simply an object with property names & values) to my ActiveXObject. I can’t find anyone who has successfully and simply passed complex data from javascript to an ActiveX object.
My ActiveX object is being loaded in IE, and it’s mine so I can change the method signature & code to whatever will work. I also have control over the structure of the javascript.
Without a simple way of doing this I’m thinking of url-encoding the data and sending it as a string. But that does seem a little silly if it’s possible just to pass an object.
The ActiveX object is coded in C# if that makes any difference…
I found the best way to do this was to send JSON strings back & forth. This is very simple for both simple data and complex data.
To send data from an ActiveXObject to javascript, just use a StringBuilder or similar to format the data as JSON.
To send data from javascript to an ActiveXObject, use JSON library within javascript to encode the data, then use a JSON parser in .net like JSON.Net to read it.
Alternatively, for real simple cases where you don’t want a JSON parser you can use use URL-encoded strings.