How do I post score with AJAX?

  • Hello,

    I have a problem with posting scores and player names to my online php file. I don't have problem with getting the scores and names.

    I was following this tutorial: https://www.scirra.com/tutorials/346/online-high-score-table-ajax-php-mysql

    Do you know how to remake that savescores.php document, to allow it saving the score cross-domain?

    I will appreciate every help, thanks a lot guys!

  • Try adding this.

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

  • i got this in my getscores.php, i put it to savescore, but still not working... :/ Any idea, how to fix it?

    When i go directly to the page savescore, i can save the score there, getscores too, but in game i can only load scores, but I can't save them to that online php file. :/

  • HI EVERYBODY.

    I'm having trouble making score screen. I share with you my example. Can you give me some advice. I do not want to switch to a new layout for the score screen. I want a small window open in the game layout. However, i want to give 3 stars, 2,stars but it is a problem . when i complate level in first shoot it is 3 star. Complate second shoot it is 2 star third or more try it is 1 star. goo.gl/B5csdx

  • sizcoz try with .htaccess file. Create ".htaccess" file in the directory where you have your script (the one which ajax is calling)... with the following content

    <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
    </IfModule> [/code:3ernqrjl]
    
    It basically does the same, but you might have some security restrictions enabled in Apache especially if you have shared hosting.
  • I am having a similar issue, I only need to post to the database, i don't need to show results in layout. My problem is it will work once, then the next time I load the page it no longer posts when I submit. I have followed the high scores tutorial and the login one. Both are pretty straight forward.

    My ultimate goal is to have it so upon either start up or completion of load of my final end game layout I would like it to post the score to the database without having to hit a submit button.

    I can upload a capx if need be.

    Thanks in advance.

  • Hello , you managed to develop the login system ? Show User data logged ?! If so, you can provide the .capx file?! My email:

    Not can do it , if you know someone help me , please!

  • Lima I didn't do login, mine was just a quick post on load. Did you set up your mysql database and follow the steps in the tutorial? If you want to pm me with login creds to your db and the capx I can look at it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • luvleggs, i appreciate that, but what it lacks is different from your ... you want to save, and I want to show the data ... I will follow the post and see if I can solve my doubts.

    Sorry about my terrible English!!

  • perhaps you need to use this :

    https://chrome.google.com/webstore/deta ... ljbi?hl=en

    I used that addon for my AJAX tutorial :

    http://bikingame.com/2016/07/09/constru ... ngan-ajax/

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