Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble with creating database table using jQuery ajax
    primarykey
    data
    text
    <p>I am absolutely new to jQuery and ajax. Currently I am trying to create a table on my local sql server from a javascript file from which I am posting the statement to .php file to execute the statement. </p> <p>.js file:</p> <pre><code>function executeStatement(sqlStatement){ $.ajax({ type: "post", data: sqlStatement, cache: false, url: "api.php", dataType: "text", error: function(xhr, status, error) { var err = eval("(" + xhr.responseText + ")"); alert(err.Message); }, success: function () { alert ("Success!!"); } }); } </code></pre> <p>.php file:</p> <pre><code> require_once('PhpConsole.php'); PhpConsole::start(); debug('HERE!!!'); $sqlStatement = $_POST['sqlStatement']; $host = "*****"; $user = "*****"; $pass = "*****"; $databaseName = "db_user_data"; // Create connection $con = mysqli_connect($host, $user, $pass, $databaseName); // Check connection if (mysqli_connect_errno($con)){ echo "Failed to connect to MySQL: " . mysqli_connect_error(); } else{ $con-&gt;query($sqlStatement); header('Location: success.php'); } </code></pre> <p>I use PHP Console to debug .php files but in this case even the first log 'HERE!!!' is not printed to the console so I am wondering whether it even reaches this .php file. Anyway the event <code>success</code> within executeStatement method is reached and 'Success' printed even though there are no changes in the database.By the way the .php file is also executed on the local server. Does someone has any ideas where the problem can be??</p> <p>Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload