-3
I do not understand yet why it does not send via POST the data in AJAX, goes straight to error, and opens the Modal saying that there was the error and quickly directs to the page, even this modal not being for this... I put Alert and it does the same thing, opens the Error Alert and directs to page...
I need to understand about this situation to send my data via POST and ajax
$(document).on("click", '#updateStatusEquip', function() {
$.ajax({
type: "POST",
data: { value_id : $('#admin_id').val() },
success: function(data) {
// Check the output of ajax call on firebug console
console.log(data);
$(".modal-body-info").html("Sucesso: Status do Registro alterado com sucesso");
$("#myModalMessage").modal("show");
},
error: function () {
$(".modal-title").html("Erro");
$(".modal-body-info").html("Erro: Registro não foi inserido");
$("#myModalMessage").modal("show");
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Modal - Message -->
<div class="modal fade" id="myModalMessage" tabindex="-1" role="dialog" aria-labelledby="myModalMessage">
<form method="post" id="ze-form" >
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"></h4>
<button type="button" class="close" id="reloadTable" data-dismiss="modal" aria-label="Fechar"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<div class="modal-body-info">
<b>Registro de:</b><br>Jonhy<input type="hidden" name="admin_id" id="admin_id" value="2"><br><b>Têm certeza que deseja alterar o status desse registro?</b><br>Poderá não ser capaz de acessar o Sistema</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" id="reloadTable" data-dismiss="modal">Fechar</button>
<div class="modal-footer-button"><button type="submit" name="updateStatusEquip" id="updateStatusEquip" title="Alterar..." class="btn btn-warning">Alterar <i class="fas fa-level-up-alt ze-icon-m"></i><i class="fas fa-level-down-alt ze-icon-m"></i> </button></div>
</div>
</div>
</div>
</form>
</div>
Friend, I think you forgot to inform the data sending url
– Angelo Soares
But to avoid creating several php... wanted it to be on the same page... where opens the modal within sucess, I put an Insert in php with isset condition of the value in POST
– Luccas Alves Gaulia
You must enter the url to which this data will be sent... If you want to send to the same URL, enter the url you are.
– Angelo Soares
Even added, nothing has changed.... url: 'index.php? page=equipList',
– Luccas Alves Gaulia
So I think you better give me another url so that this data is sent, it would be more organized and I believe that it would not break so much the head as this...
– Angelo Soares
What I am checking that even with another URL as propos, does not go to Sucess... The parameters are being sent, but is being directed to the error, and even with Alert, it opens the Alert and directs quickly to the main page... I think it should be related to the . js files of the page, because I see no other explanation... I’ve used $.post as well and other templates... Do they have to do with jquery I use? 3.4.1?
– Luccas Alves Gaulia