Problem with Ajax + PHP

0 favourites
  • 5 posts
From the Asset Store
Paypal PHP Supports multiple platforms, Web/html5 Android, IOS. (Including storing transaction data)
  • Hello Guys,

    I'm having problems with PHP + Ajax.

    The problem is that I am not knowing where to put my. Php

    I made an example by putting the folder C: \ Program Files \ Apache Software Foundation \ Apache2.2 \ htdocs \ construct, but failed.

    Can anyone help me?

    IMAGE

    imagebam.com/image/ffa2ae185798372

    PHP

    <?php

    if ($_GET['mode']=="save") {

    $score = $_GET['score'];

    }

    $fp = fopen("testFile.txt", "a");

    $escreve = fwrite($fp, "Test MSG");

    fclose($fp);

    ?>

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This is kind of out of the scope of this forum, since Apache and PHP have abundant ressources all over the web to learn from.

    I'd say you should have a "www" folder in your apache directory and this is where you should have a jax.php file containing your code.

    This is how you'll be able to access "http://localhost/jax.php?whatever".

    Check the How do I FAQ there are several examples treating about AJAX and PHP in the "AJAX" section, but for beginner documentation about having a local webserver and how to write correct PHP, you should make a search on google and learn from there.

  • if you placed it in \ htdocs \ construct then you should request localhost/construct/jax.php instead of localhost/jax.php

  • Fimbul, that's not quite right, Construct 2 runs its own preview server. So unless you run Apache on a different port (e.g. localhost:80) and specifically AJAX the URL "http://localhost:80/construct/jax/php", it won't work. Currently I think it is easiest to run a server on the open web, e.g. example.com/jax.php - then you don't have to change anything from preview to export, either.

  • Was actually wondering how to get files into the local server. Stumbled on this thread, sweet.

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