Request AJAX/PHP Help

Get help using Construct 2

Post » Mon Jul 09, 2012 7:02 pm

What I am doing is very simple, I have a PHP file to get high score from my database.

As you can see the PHP file works fine.
http://iretrogames.com/cgi-bin/getscores.php

My project:



When I run it and click the button, txt3Name value is blank.

However, if I just create a file with some text, save it as php and use the same above process, when I click the button txt3Name shows the text.

Obviously the getscores.php file is working correctly as you can see from going to the url, so I don't konw why the AJAX.LastData is empty.

Would appreciate any help. I'm planning on doing a video tutorial on making an online high score table, but I just can't get past this one little thing :).
Thanks.ArcadEd2012-07-09 19:04:00
B
94
S
29
G
11
Posts: 1,545
Reputation: 20,993

Post » Mon Jul 09, 2012 7:15 pm

I think I might have it figured out. Even though the text on the website looks to be in one long string, the source code fro the page shows line breaks :).

B
94
S
29
G
11
Posts: 1,545
Reputation: 20,993

Post » Mon Jul 09, 2012 7:22 pm

Which I guess brings me to another issue. Now I'm trying to get all the results from the query_array to show up in one text block.

// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
echo $rows['name'] . "|" . $rows['score'] . "|";


That seems to make a line break with each passing of the while statement
B
94
S
29
G
11
Posts: 1,545
Reputation: 20,993

Post » Mon Jul 09, 2012 7:26 pm

I'm not sure, but I think you're missing an XML object to load the Ajax.LastData into. See here: http://www.scirra.com/tutorials/61/ajax-example-with-construct-2/page-1

Don't forget to make sure to use an XPath expression when you try to read the xml.

Here's an example: XML.StringValue("/Catalog/data/@artist")
http://www.liquid-technologies.com/xpath-tutorial.aspxTaurian2012-07-09 19:28:20
Epic Space Online - Google it!
B
34
S
10
G
5
Posts: 165
Reputation: 6,637

Post » Mon Jul 09, 2012 7:30 pm

I'm running through the tutorial again, just in case I missed something. Thanks.ArcadEd2012-07-09 19:41:20
B
94
S
29
G
11
Posts: 1,545
Reputation: 20,993

Post » Mon Jul 09, 2012 7:39 pm

OK, well I got the php file to display correctly now
http://iretrogames.com/cgi-bin/getscores.php

But now it's acting like the Ajax process is not completing because the text is not changing to blank, it's not changing at all.

Sorry, I am kind of using this thread as a talk out loud. Sometimes it helps me find the issue, plus with help from others. I just know lots of people have been asking for a tutorial to do high scores and I would to put one together, if I can do it myself first HA.
B
94
S
29
G
11
Posts: 1,545
Reputation: 20,993

Post » Mon Jul 09, 2012 7:49 pm

Ureka! :). I got it all worked out now I think.
B
94
S
29
G
11
Posts: 1,545
Reputation: 20,993

Post » Mon Feb 10, 2014 11:00 pm

Hey, ive been having some problems with this too, could you share the capx and php files?

B
34
S
8
G
7
Posts: 498
Reputation: 7,753

Post » Mon Feb 10, 2014 11:46 pm

This is really old. I have since made a tutorial on it that might help.

https://www.scirra.com/tutorials/346/online-high-score-table-ajax-php-mysql ArcadEd2014-02-10 23:47:14
B
94
S
29
G
11
Posts: 1,545
Reputation: 20,993


Return to How do I....?

Who is online

Users browsing this forum: PixelatedTrip and 0 guests