AJAX and POST

0 favourites
  • 14 posts
From the Asset Store
We present to you “Post Apocalyptic Trailer” – our newest hard hitting, bass rumbling designed movie trailer collection.
  • Can someone please give me a very simplified step by step process on how to send scores to a database?

    Everything I read isn't making sense to me.

    I have tried to use request and send. I can't even get it to call the PHP page?

    I am very beginner learner. I built a very basic game but I just need to send the scores. Can someone please help.

    Tagged:

  • Can someone please give me a very simplified step by step process on how to send scores to a database?

    Everything I read isn't making sense to me.

    I have tried to use request and send. I can't even get it to call the PHP page?

    I am very beginner learner. I built a very basic game but I just need to send the scores. Can someone please help.

    LanieCoder

    I am going to need to see your PHP script but bascially

    You have a PHP script on your site as well as a MySQL database with the table scores in it,

    You then send an ajax post request to your site.com/phpscript.php containing the post info and the PHP script should put that info in the database.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I understand what is supposed to happen but I'm having issues with the parameters? Whats the tag for?

  • I understand what is supposed to happen but I'm having issues with the parameters? Whats the tag for?

    LanieCoder

    Here is a basic example on how to get this working with uploading a file to your server:

    Here are the events

    Here is the PHP script that needs to be hosted on your site.

  • > I understand what is supposed to happen but I'm having issues with the parameters? Whats the tag for?

    LanieCoder

    Here is a basic example on how to get this working with uploading a file to your server:

    Here are the events

    Here is the PHP script that needs to be hosted on your site.

    Great Explanation! Superb! Thank You, is only example I could understand!

    I may ask you... and its possible to receive data into the C2 back from server this way?

  • > > I understand what is supposed to happen but I'm having issues with the parameters? Whats the tag for?

    >

    >

    > LanieCoder

    >

    > Here is a basic example on how to get this working with uploading a file to your server:

    >

    > Here are the events

    >

    >

    >

    > Here is the PHP script that needs to be hosted on your site.

    >

    >

    Great Explanation! Superb! Thank You, is only example I could understand!

    I may ask you... and its possible to receive data into the C2 back from server this way?

    Yes as with PHP you can echo as a JSON for mat and c3 can parse and read JSON data

  • Thank you for your answer,

    there is not problem parsing JSON,

    I wonder if you could be so kind to post an example with what is need in PHP side and Construct events too as you made before but this time in reverse direction (send from PHP to Construct)

    thanks in advance

  • Hi here is a quick example

    In your PHP file insert the following:

    echo "{"name":"John", "age":31, "city":"New York"}";

    The script will output the following:

    {"name":"John", "age":31, "city":"New York"}

    Now In construct insert the JSON and AJAX plugins then add the following events:

    1. Global Variable Name (Should be a string)
    2. On start of layout ----> Ajax request URL (URL is the URL to your php script)
    3. On AJAX completed ----> JSON parse AJAX.lastData
    4. set Name to JSON.get("name")
  • Great man!!!!

    thank you so so much!

  • Sorry for my questions, but you are helping me a lot!!

    I got one more, hope not to bother you...

    how to request some data from PHP? (construct side, PHP will figure it out myself with a collegue)

    example to request data from "Maria" (instead of John) to get her data:

    {"name":"Maria", "age":31, "city":"New York"}

  • hugoneYou can check in the How do I FAQ for Construct 2 in the category AJAX, there should be topics answering your question.

  • Kyatric I will do, thanks!

  • Sorry for my questions, but you are helping me a lot!!

    I got one more, hope not to bother you...

    how to request some data from PHP? (construct side, PHP will figure it out myself with a collegue)

    example to request data from "Maria" (instead of John) to get her data:

    {"name":"Maria", "age":31, "city":"New York"}

    It all depends on the JSON so lets say I have the following:

    {"name1":"Maria", "age1":31, "city1":"New York", "name2":"John", "age2":31, "city2":"New York"}

    To get "Maria" you do JSON.get("name1")

    To get "John" you do JSON.get("name2")

  • Woow, thank you again!

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