Browser execute script return?

0 favourites
  • 5 posts
From the Asset Store
This is a single chapter from the Construct Starter Kit Collection and the Student Workbook from the Workshop.
  • 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.

    Thanks

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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.

  • Bumping for sanities sake.

    Or should I expect some other method to parse json soon?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)