Мне нужно обновить поле в моей базе данных, когда я нажимаю на кнопку.Для этого я использую запрос.Я работаю с ZendFramework, поэтому я использую модель MVC.Если у вас есть вопрос о моем коде или что-то, просто спросите меня.
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) {
}
}
});
});
});`
Запрос:
public function putSupervision($idDepot) {
$this->executeQueries("
Update DEPOT set STATUT_DEPOT = 51103 where ID_DEPOT = ".$idDepot."
commit;"
);
return $this->getAllRows();
}
}
КОНТРОЛЛЕР
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ée en supervision </button>
</div>
КОНСОЛЬ