No response after form submission and page just auto reload
createComment is an inbuilt function.
Reference : developer.mozilla.org
try a different function name.
Ajax Form Submission Works But No Response
How about you do this in your javascript:
var delAccount = function(e) {
e.preventDefault();
// Get the option that will be deleted to remove it
// later on success.
var opt = $('#deleteMenu').children(':selected');
var data = $('#deleteAccountForm').serialize();
$.ajax({
type: "POST",
url: "inc/functions.php",
data: data,
beforeSend: function() {
$('#results').html('processing');
},
error: function() {
$('#results').html('failure');
},
success: function(response) {
$('#results').html(response);
// Remove the option
opt.remove()
},
timeout: 3000,
});
};
Regarding the message for #results, in your PHP I only see you respond if there's an error, unless the response for success is created and dispatched somewhere else?.
[Edit]
The response should be created, and in this case also sent, at the end of the try
block. If the script gets to that part, it means everything went fine.
function delete_account() {
require(ROOT_PATH . "/inc/database.php");
$deleteAccount = $_POST['deleteMenu'];
try {
$results = $db->prepare("DELETE FROM account WHERE account_id_PK = ?");
$results->bindValue(1, $deleteAccount);
$results->execute();
// If everything goes fine here, you can output the
// success response.
// Echo getAccounts() assuming it returns HTML (string).
// Otherwise, setup your HTML and then echo it.
echo getAccounts();
} catch(Exception $e) {
echo "ERROR: Data could not be removed from the database. " . $e;
exit;
}
}
no response when form is sent
To post your form you need method = "post"
instead of action = "post"
<form action = "createtable.php" method = "post">
instead of
<form action = "createtable.php" action = "post">
Also, You need to add the value in your radio input as well,
echo '<input type = "radio" name = "db" value="'.$row[0].'" />' . $row[0] . "<br>";
Related Topics
Encoding CSV File With Arabic Content
How to Convert Jquery Ajax Success Data to a PHP Variable
Join Category and Subcategory in Same Table
Checking If Email Is in MySQL Database in PHP
Fatal Error: Call to Undefined Function Mysqli_Connect()
Nginx Error Recv() Failed (104: Connection Reset by Peer)
Internal Server Error While Run Laravel on Localhost
How to Use Find in Set for User Rankings Based on Score
In Laravel,How to Use Foreach Loop
Laravel Drop Down Multiple Values from Db in Drop Down
Dynamically Display a CSV File as an HTML Table on a Web Page
Generate Preview Image from Video File
How to Get Toggle Button Working With PHP
Install PHP Intl Extension on Macos