I have a web application in PHP where I generate income to an item. I can assign movements to this item. I do it with a FORM POST
. Besides I have a button where I can eliminate that assignment.
This method was done with JSON
.
$(document).ready(function() {
$('.view_data').click(function() {
var code = $(this).attr('id');
var val = $('#valor').val();
$.ajax({
type: 'POST',
url: 'JSON/deleteJSON.php',
data: {
'code': code,
'val': val
},
success: function(data) {
location.reload();
}
});
// End AJAX function
});
});
</script>
In my PHP
<?php
include_once '../include/conexion.php';
$codmenu = $_POST['code'];
$id = $_POST['val'];
$sql = "DELETE FROM ACT_FKAgenda WHERE id_fkagenda =$codmenu";
$resultt = mysqli_query($conn, $sql);
if($resultt) {
header("Refresh:0; url=../add-horas.php?id=$id&Borrado");
} else {
header("Refresh:0; url=../add-horas.php?id=$id&ERROR");
}
?>
When I delete it, it refreshes me on the same page, since in JSON SUCCESS I have the function location.reload();
but my question is if I can do something like this in JSON
header("Refresh:0; url=../add-horas.php?id=$id&Borrado");
Where it refreshes in the page of the item that I am assigned movements and apart I add the $Borrado
to the URL so I can use a $ _GET and show a message.
I hope to have explained myself well. Greetings.