How to Use Ajax, JSON, and arrays?

  • Hello everyone. I have been scouring over forums and no luck with what I am trying to do.

    My goal is to have a login system on an app built with C2 and eventually need to read/write to make the app sync to the web version of the app that is already built using various web endpoints. I think using AJAX requests to json data will work but I cannot seem to parse the data to get the key and values of JSON data into a variable.... I'm getting the whole string as a variable which doesn't help.

    EVENT 1: on login button clicked AJAX request: "/token.php?username="&Username&"&password="&Password&"&service=mobile_app"

    (This part is functional) and I get back a long string set to a variable as follows {"token":"long string of numbers here","privatetoken":"longerstring of numbers here"}

    From what I gather, I need to get this information into an array, so that I can check to see if this token exists. If it doesn't exist I get this: {"error":"Invalid login, please try again","errorcode":"invalidlogin","stacktrace":"* line 104 of \/login\/token.php: exception thrown\n","debuginfo":"\nError code: invalidlogin","reproductionlink":"https:\/\/website.com\/"}

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)