How do I post score with AJAX?

Get help using Construct 2

Post » Thu Mar 03, 2016 2:42 pm

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! :)
B
10
S
1
Posts: 42
Reputation: 620

Post » Thu Mar 03, 2016 4:19 pm

Try adding this.

header('Access-Control-Allow-Origin: *');
Bushy Ball\Boatman Bill\Sticky Web\Snake

Image ImageImageImage

During the gold rush it was a good time to be in the pick and shovel business
B
43
S
12
Posts: 241
Reputation: 5,045

Post » Thu Mar 03, 2016 8:41 pm

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. :/
B
10
S
1
Posts: 42
Reputation: 620

Post » Thu Mar 03, 2016 10:04 pm

Message: imczx can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
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. https://goo.gl/B5csdx
B
6
S
2
G
1
Posts: 17
Reputation: 573

Post » Fri Mar 04, 2016 2:44 am

@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
Code: Select all
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>


It basically does the same, but you might have some security restrictions enabled in Apache especially if you have shared hosting.
ImageImage
B
27
S
16
G
68
Posts: 945
Reputation: 38,599

Post » Fri Jun 24, 2016 2:09 am

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.
B
29
S
10
G
3
Posts: 69
Reputation: 3,515

Post » Mon Jul 25, 2016 2:37 am

Message: Cyelho Lima can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Hello , you managed to develop the login system ? Show User data logged ?! If so, you can provide the .capx file?! My email: [email protected]

Not can do it , if you know someone help me , please!
B
8
S
3
G
1
Posts: 21
Reputation: 1,200

Post » Mon Jul 25, 2016 2:53 am

@cyelho 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.
B
29
S
10
G
3
Posts: 69
Reputation: 3,515

Post » Mon Jul 25, 2016 3:11 am

@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!!
B
8
S
3
G
1
Posts: 21
Reputation: 1,200

Post » Mon Jul 25, 2016 5:07 am

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/
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
62
S
14
G
2
Posts: 286
Reputation: 6,576


Return to How do I....?

Who is online

Users browsing this forum: BadMario, stevenode and 6 guests