UPDATE PDO, AJAX, PHP Object Oriented

2

I have the following function within my class

public function update(){

                try{

                    $stmt = $this->conn->prepare("UPDATE Tabela SET Dado1 = :Dado1, Dado2 = :Dado2, Dado3 = :Dado3 WHERE DadoId = :DadoId");
                    $stmt->bindParam(':Dado1', $Dado1, PDO::PARAM_STR);
                    $stmt->bindParam(':Dado2', $Dado2, PDO::PARAM_STR);
                    $stmt->bindParam(':Dado3', $Dado3, PDO::PARAM_STR);
                    $stmt->execute();

                    if ($stmt > 0)
                    {

                        header ( "location:retorno.php" );

                    }

                    return $stmt;

                }catch (PDOStatement $excption){

                    header("Location: ./error.php?err=Unable to insert");
                    echo 'Erro: '.$exception->getMessage();         
                    return null; 

                } 
 }

And I usually do a post method to send it:

$up = new Classe();

if($_SERVER['REQUEST_METHOD']=='POST'){

    if(isset($_POST['btn-update']))
    {
        $stDado1= strip_tags($_POST['stn-Dado1']);
        $stDado2 = strip_tags($_POST['stn-Dado2']);     
        $stDado3 = strip_tags($_POST['stn-Dado3']);
        $sendInsert = $up->update($stDado1, $stDado2, $stDado3);
    }

    exit();
}

But I have a problem, my Dado3 is a TAG <div> , which receives a Text, I get through% J% of JQuery, because what was recorded in the database is a HTML code.

<form method="POST">
   <div class="form-group">
    <label>Dado 1</label>                                                            
        <input class="form-control" name="dado1" type="text" >
    </div>
    <div class="form-group">
    <label>Dado 2</label>
        <input class="form-control" name="dado2" type="text">                                                       
    </div>
    <div class="form-group">
        <label>Dado 3</label>
        <hr>
        <div name="dado3" contentEditable="false">                                                                
        </div>
    </div>
<hr>
<a class="btn btn-warning edit">Editar</a>
<a class="btn btn-warning cancel">Cancelar</a>
<button type="submit" name="btn-update" class="btn btn-danger ">Salvar</button>

</form>

Is there any way I can send this .html() to the bank via ajax or some other method?

    
asked by anonymous 27.09.2016 / 22:34

0 answers