Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JS/PHP/ZendFramework - update my datatable when i click on button with php and ajax

I have to update a field in my database when I click on a button. To do this I use a query. I am working with ZendFramework, so I use MVC model. If you have question about my code or something just ask me.

JS :

 `// Gestion du bouton de Remontée en supervision
$("#remontee-supervision").click(function() {
    // Suppression des filtres en session.
    $.ajax({
        type : 'POST',
        url : '/supervision/admin/ajaxremonteesupervision',
        async : true,
        data : {
            $idDepot : $("#idDepot").val()
        },
        success : function(response) {
           var vResult = jQuery.parseJSON(response);
           alert('remontee-supervision');
           console.log(vResult.result);
           if (!vResult.result) {

           }
        }
    });
});  

});`

Query:

public function putSupervision($idDepot) {
     $this->executeQueries("
     Update DEPOT set STATUT_DEPOT = 51103 where ID_DEPOT = ".$idDepot."
     commit;"
            );
    return $this->getAllRows();
}
}

CONTROLLER

public function ajaxremonteesupervisionAction() 
{
    $this->_helper->layout->disableLayout();
    $this->_helper->viewRenderer->setNoRender();
    //parametre passé via ajax
    $params = $this->_getAllParams();
    $update = NULL;
    //lancement
    $oDepotAdmin = new Services_DepotAdmin();
    $update = $oDepotAdmin->putSupervision();


    $response['result'] = $update;

    echo json_encode($response);

}

HTML

 <div id="bouton">
            <button id="remontee-supervision">Remont&eacute;e en supervision </button>
 </div>

CONSOLE

enter image description here

like image 403
Nico Avatar asked Nov 26 '25 08:11

Nico


1 Answers

The error message is pretty clear:

Missing argument 1 for Services_DepotAdmin::putSupervision()

So, fix your code:

$update = $oDepotAdmin->putSupervision();

With

$idDepot = $params['$idDepot'];
$update = $oDepotAdmin->putSupervision($idDepot);
like image 184
Felippe Duarte Avatar answered Nov 27 '25 20:11

Felippe Duarte



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!