Ajax doesn't post my data

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 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:

    <img src="http://www.pixentral.com/pics/1sS5LxdqBWrbk0vRk2qMP4lKorZ.jpg" border="0" />

    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

  • 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:

    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'";
    $retval = mysql_query( $sql, $conn );
    if(! $retval )
      die('Could not update data: ' . mysql_error());
    echo "Updated data successfully\n";
    // close connection 

    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 ;-)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Anyone?

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