Search the Community
Showing results for tags 'mysqli function'.
-
Hi I'm trying to call this following php function from a ajax call but i can't get it to work class EBSPMA { function visitaValidacaoByUserAdmin($userid) { if(isset($_POST['action']) && !empty($_POST['action'])) { $id_visita = filter_input(INPUT_POST, 'id_visita'); $plano =filter_input(INPUT_POST, 'plano '); $valido = filter_input(INPUT_POST, 'valido'); $sql = "UPDATE `new_visitas` SET `plano`= ?,`valido`= ? WHERE `id_visita` = ?"; $stmt = $this->connection->prepare($sql); if ($stmt === false) { trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $mysqli->error, E_USER_ERROR); } $stmt->bind_param('ssi',$plano, $valido, $id_visita); if (!$stmt->execute()) { echo json_encode(array('status' => 'error', 'message' => 'Opppss...A visita ainda não foi validada')); } else { echo json_encode(array('status' => 'success', 'message' => 'A visita já foi validada...Obrigado')); } $this->connection->close(); } } } and this is my ajax call function submitForm2(formId){ var id_visita = $('input[id="id_visita"]').val(); var plano = $('input[id="plano"]').val(); var valido = $('input[id="valido"]').val(); $.ajax({ url: 'include/fg_membersite.php', type: 'POST', data : {action: 'visitaValidacaoByUserAdmin()', 'id_visita': id_visita, 'plano': plano, 'valido': valido}, dataType: 'json', success:function(response){ alert(response.message); $("#myModal2").modal('hide'); window.location.reload(true); } }); } Nothing happens....any help please??