0
My code is working up to the point where the ajax has to pick up the answer to print on the screen, the Insert is being done normally in the comic, if I change the return $("#requests"). html(data); to $("#requests"). html(data); works by returning serialize, something is escaping me?
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#pedidos').submit(function(){
var dados = jQuery( this ).serialize();
jQuery.ajax({
type: "POST",
url: "pedidos.php",
data: dados,
success: function( data )
{
$("#pedidos").html(data);
}
});
return false;
});
});
</script>
below the php page
$nome = trim($_POST['nome']);
$recado = trim($_POST['recado']);
$error = FALSE;
if (!$error) {
$sql = "INSERT INTO `pedidos` (`nome`, `recado`) VALUES "
. "( :nome, :recado)";
try {
$stmt = $DB->prepare($sql);
// bind the values
$stmt->bindValue(":nome", $nome);
$stmt->bindValue(":recado", $recado);
// execute Query
$stmt->execute();
$result = $stmt->rowCount();
if ($result > 0) {
$_SESSION["errorType"] = "success";
$_SESSION["errorMsg"] = "Sua mensagem foi enviada com Sucesso.";
} else {
$_SESSION["errorType"] = "danger";
$_SESSION["errorMsg"] = "Falha ao enviar.";
}
} catch (Exception $ex) {
$_SESSION["errorType"] = "danger";
$_SESSION["errorMsg"] = $ex->getMessage();
}
}
I don’t understand what the problem is.
– rray
updated page and not return on div id="orders"
– Arsom Nolasco
the date will return with whatever comes from the.php requests, in the code I have not seen what you are wanting to print
– André Vicente