0
I’m trying to send two variables to a php file. I tried it first with a variable, and it was working. When I put in the second variable, it stopped working.
Javascript function:
function mensagem() {
var name=confirm("Pressione um botão.");
if (name==true)
{
obs = prompt("Observações: ");
alert(obs);
$.ajax({
type: "POST",
url: "temp.php",
data: {name: id, obs1: obs},
success:function(data){
window.location.reload();
}
});
}
else
{
alert("Erro");
}
}
File temp.php
:
<?php
require_once('conn.php');
$id = $_POST['name'];
$obs = $_POST['obs1'];
//$query = "UPDATE relatorio SET estado='1' WHERE id = $id ";
$query = "UPDATE relatorio SET estado='1', observacoes = $obs WHERE id = $id";
if(mysqli_query($conn, $query)){
echo json_encode(array('success' => 1));
}else{
echo json_encode(array('erro' => 0));
}
echo json_encode($result);
Anyone can help?