How do I get the userid using AJAX

0 favourites
  • 6 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hi,

    I have read all the tutorial about AJAX in this site but I still can't figure this out.

    I need to get the userid variable from a PHP page.

    Here is what I am doing:

    HERE is what I am getting

    How can I only get the variable and not the whole page?

    thanks,

  • You should show the PHP script because this is the place where you return data.

    Basically you should have something like:

    <?php 
    $userId = "whatever value you want";
    die($userId); 
    ?>
    [/code:2kz1tacd]
    
    Also you are sending an empty GET variable in your url "[b]?userid[/b]" part which is not needed. So cut your URL at the end and echo variable in PHP script and that's it.
  • ,

    Your solution works but the problem is that I don't have access to the PHP file. This is kind of an API, I just trying to get the userid from a PHP page using Construct2.

    Is there another way to do that?

  • .. the problem is that I don't have access to the PHP file.

    Is there another way to do that?

    I'm guessing that you'll need to cut out unwanted parts..with tokenat,left,right or regex

    e.g

    set Text to.........tokenat(AJAX.LastData,0,"<")

    will return only usersad64gfa6df4asd6f5454

  • korbaach

    Yes. It is a good idea but I need to single out the userid only. I am not sure where it is in the code. So I can't index it using the tokenat.

    I guess there is no solution for that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What if I use another PHP file to retrieve the userid and then pass it to Construct2?

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