Browser execute script return?

Get help using Construct 2

Post » Wed May 15, 2013 3:49 pm

I was wanting to try to parse some json with json.parse() using the the new browser object execute script, but I dont see how to get the return back into C2 in a useful manner. Is there an expression I'm missing?

Also any idea's on how to deal with shoving the results into a dictionary, or webstorage?
Specifically a return with multiple values.

Thanksnewt2013-05-15 15:52:42
Image Image
B
164
S
49
G
123
Posts: 7,783
Reputation: 84,020

Post » Wed May 15, 2013 4:09 pm

Yes, you're missing the ExecJS browser expression, which executes Javascript and returns the result. Only strings or numbers can be returned though. If you need more than that, use the Javascript SDK.
Scirra Founder
B
373
S
218
G
83
Posts: 23,439
Reputation: 185,848

Post » Wed May 15, 2013 4:30 pm

OK so I should treat Browser.ExecJS(Javascript) as a value.

I'll give that a try. Thanks

That's more of a warning than an affirmation.



newt2013-05-15 17:01:56
Image Image
B
164
S
49
G
123
Posts: 7,783
Reputation: 84,020

Post » Wed May 15, 2013 5:12 pm

OK, well that could have gone worse I guess.
I found a bit of code, and modified it:
Browser.ExecJS("var jsontext ="& AJAX.LastData&";"
&"var image = JSON.parse(jsontext);
document.write(image.avatar_url );)")

Where supposedly that turns the string into an object with one of its key pairs being avatar_url.

That however returns an error.

Again I think my problem is what to do to get the return.
No idea if document.write is the way to go, or if I'm even in the ballpark with the json.parse.
Image Image
B
164
S
49
G
123
Posts: 7,783
Reputation: 84,020

Post » Thu May 16, 2013 7:44 pm

Bumping for sanities sake.

Or should I expect some other method to parse json soon?
Image Image
B
164
S
49
G
123
Posts: 7,783
Reputation: 84,020


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests