Ajax doesn't post my data

Get help using Construct 2

Post » Sun Feb 09, 2014 10:39 am

Hi all,

Still bugging around with AJAX.

All my requests etc are working but now i actually want to write my data to a DB.

At this very moment i do not care yet about safety so..

All i want to do is write a name and score to the DB. My PHP script works fine, my AJAX post works fine also.. But this is if i manually input the name and score.

What i do have:


Can any one explain to me why this is not working?

So again,
If i change the link and input the name and score myself it does work. So somehow it will not get my username.Text and/or the global variable; Score
B
10
S
4
G
3
Posts: 169
Reputation: 2,519

Post » Sun Feb 09, 2014 11:40 am

Update: i see everything manually works.. So my guess is that something is blocking my request.

I did use the:
header('Access-Control-Allow-Origin: *');

But to bad without result.

Here is my complete script:

[code]
<?php
header('Access-Control-Allow-Origin: *');

$dbhost = '';
$dbuser = '';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}

$name = $_GET['name'];
$highscore = $_GET['highscore'];

$sql = "UPDATE hiscore SET name = '$name', score = '$highscore'";

mysql_select_db('*****');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully\n";

// close connection
mysql_close($conn);
?>
[/code]

Oh ps.. Ye i know somehow i made my database "hiscore" instead of Highscore.. So i'm aware of that it's not a typo ;-)Allardje2014-02-09 11:40:29
B
10
S
4
G
3
Posts: 169
Reputation: 2,519

Post » Sun Feb 09, 2014 1:29 pm

Anyone?
B
10
S
4
G
3
Posts: 169
Reputation: 2,519


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests