How do I POST Score using AJAX?

0 favourites
  • 3 posts
From the Asset Store
We present to you “Post Apocalyptic Trailer” – our newest hard hitting, bass rumbling designed movie trailer collection.
  • Hi Guys,

    This may be a dumb question, but POST via AJAX seems not to be working or at least using the online Leaderboard methods mentioned here and here.

    I have updated the PHP/MySQL to conform with version 7.2 and both the savescore.php and getscores.php seem to be working fine as I can read the scores and names I manually added to the database and when I click the submit button I get a new entry in the database but without a name and just a zero (so not getting the score).

    This is what I have in the AJAX Add Action POST to URL DOMAIN_SCORES & "savescores.php?name=" & txtPlayerName.Text & "&score=" & Score.

    Anyone got an idea of what I'm doing wrong?


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I was hitting my head on this wall a few days ago.

    What I've done to solve this was wrapping all variables using the URLEncode system expression. So your AJAX action would be like this:

    DOMAIN_SCORES & "savescores.php?name=" & URLEncode(txtPlayerName.Text) & "&score=" & URLEncode(str(Score))

    *Note also that you need to convert your integer/float Score to a string.

  • Hi influogames,

    Thank you for the reply. Please accept my apology for the delayed response, apparently it was a better idea to go and stand in shop queue's all day rather than try to sort this problem out - or at least that's what I was told :)

    I have managed to have a go with the code you provided but still no luck, it still doesn't appear to be sending anything via AJAX POST. Yet, if I pre-fill the variables in the php page it posts the information to the database as I would expect.

    I don't suppose anyone has a working version they could post? Not the ones already listed on this site as they don't seem to be working form me. Failing that, any more ideas would be appreciated.


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