Sending data via Ajax to Save in MySQL Failed

0 favourites
  • 9 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • Link to .capx file (required!):

    Steps to reproduce:




    Observed result:

    Sending the data via AJAX POST the parameter is not able to send to the PHP script to save the parameter passed which are taken from Input Form, but it is writing blank which means the parameter (data) was not send.

    I followed the sample.   Yes, database table had been created and connection is valid but it is writing blank.

    Expected result:

    Insert parameter passed which was a Name and a Message (text) field into the Table with the values in it

    Browsers affected:

    Chrome: yes

    Firefox: yes

    Internet Explorer: yes

    Operating system & service pack:

    Windows 7 Starter

    Construct 2 version:


    version r127

  • Closing, no .capx provided. For this type of bug you ought to share the server-side code you're using as well in case there's a problem with that. AFAIK lots of people are using the AJAX object to post and get successfully, so I'd double check the problem isn't your end.

  • You don't need to include the ? in the data field.

    <img src="" border="0" />

  • Hi,

    Sorry, the said file can be downloaded in the link below (just uploaded).

    The PHP code is below (from the file record-msg.php):



    * Vinson Tan

    * 2013




       $vin = "../connect.php";

       if ( file_exists( $vin )) {

          require( $vin );

       } else {

           $vin = "connect.php";

           if ( file_exists( $vin )) {

              require( $vin );

           } else {

                $vin = "../../connect.php";

                if ( file_exists( $vin )) {

                   require( $vin );

                } else {

                      $vin = "../../../connect.php";

                      if ( file_exists( $vin )) {

                         require( $vin );

                      } else { echo "Sorry, $vin was not found  "; }





       $fname = $_GET['fname'];

       $fmsg = $_GET['fmsg'];


       $sqlstr = "insert into construct_user_list (playerid, msg) values ('".






       mysql_query( $sqlstr );





    Thank You.


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi,

    I have just corrected and uploaded a new version where I have removed the "?".

    However; i am getting a " Refused to set unsafe header "Content-Length " when I use the Developer Tools -> Console.

    Please advise as i am still writing blanks.

    Thank You very much.


  • That should be $_POST not $_GET :)

    You're right, there is a console error in Chrome but it still seems to be making the request successfully. (@Ashley

  • Hi,

    Yes, i made the changes on my localhost and it is working even if the said Error from console is there.

    I am also trying to Request data off the server-side the PHP script is below (for return-msg.php):



    echo "This is a Return value from an AJAX call...";


    I have added the lines below in the Project file (sorry, i have not uploaded an updated copy yet but i will as soon as i have a chance too).


    Request "http://localhost/testing-only/return-msg.php"



    Then, I added


    on "GetData" completed

    returnText (text)

    Set text to AJAX.LastData

    However; i am not able to receive the said Echo'd string message.

    Please advise and Thank You again for the much support.

    Is there a list of updated Tutorials that i can work with ?

    Thank You very much again for the much support.

    I like the product very much and will be getting my own copy soon, i just wanted to know more about the said product as i am an urgent little game that i wanted to work on and needed to know more about the data handling side.

    Kind regards.


  • Server configuration is out of the scope of this forum. You'll need to ask on a more relevant site e.g. StackOverflow. Note the server must send the header "Access-Control-Allow-Origin: *" in order to permit requests from any origin.

  • Hi,

    Yes, it is working having the header('Access-Control-Allow-Origin: *'); added does it.

    Is there a possibility to resolve the Error(s) found in the console ?

    Thank You.


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