No Response from a Form

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



Leave a reply



Submit