how to use Ajax lastdata?

0 favourites
  • 7 posts
  • Hello everyone.

    it will be several days that I can not use Ajax to get the data from a php file.

    here is my code:

    $test = $_GET["test"];

    3 line of code with a simple variable with a $ _GET inside.

    on the example there is no interest.

    it's just for the test.

    here is my visual code on construct 2 :

    what I would like and recover what my variable contains.

    here is the location of my exported project and at the same time the location of the php file :

    they and put at the root of my local server.

    my local server and create with xampp.

    I saw that sometimes they had to meter :

    header('Access-Control-Allow-Origin: *');

    on my php file.

    except that every time nothing happens.

    the text remains empty.

    I really need help.

    if I send data to MYSQL there is no problem.

    if I want to retrieve data from a variable it does not work.

    I tried to use: On error.

    nothing changes .

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I seem to remember someone recently having similar trouble - until they used ssl.

    so, try installing a free ssl certificate and use https://

    see this thread:

    https://www.construct.net/en/forum/construct-3/how-do-i-8/insert-data-mysql-using-ajax-148227?kws=ssl%2bcertificate

  • Hello.

    thank you for your reply !

    I took some time to answer you because I set up the SSL certificate I had to buy a server temporarily for the test.

    but I always get the same problem with one thing.

    now ajax returns to me the value of an error.

  • The AJAX.LastData, using your PHP page will return exactly the same thing as if you opened it with a browser.

    So you might want to "echo" your variable somewhere along the way, so the AJAX call can return it.

  • so it's not safe if I have to go through an echo for ajax to return a value .....

  • That's basically your only way. If you want the web client to know about your variable, you have to send it. Now if that data is sensitive, HTTPS will be your friend.

  • Hello.

    I finally succeeded after following your advice.

    I wanted to know if I make a login system with AJAX can then log on?

    how to open it?

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