Here are the steps I'd like to take:
1) User enters search term into box in silverlight, then presses enter
2) Search term is passed into javascript via C# code: HtmlPage.Window.Invoke("CallAPI", SearchText);
3) CallAPI function hits the API via $.getJSON & returns a value into the JS callback function [this is already done]
4) Resultant object is returned to the Silverlight/C# page for display in silverlight UI
I can do everything except step 4. How do I get a JSON object from Javascript into C#? I've been working on this for the last few hours, and this is what I thought would do it:
ScriptObject myScriptObject = (ScriptObject)HtmlPage.Window.Invoke("CallWordStreamAPI", SearchText);
I set a breakpoint in my JS & validated that the object in my return statement is definitely populated with the 20 rows of data, as expected.
I set a breakpoint in my C# (ScriptObject myScriptObject = ....), and myScriptObject is null after the call. If I set a breakpoint in firebug/chrome dev at the line "return r" (my object), I can see there are 20 items listed in r.data. If I set a breakpoint after the myScriptObject line listed above, myScriptObject is null.
Your help is appreciated.
Scott