In response to an AJAX call:
$.ajax({
type: "POST",
dataType: 'json',
data: {
'descripcion': descripcion
},
url: "<?php echo site_url();?>"+"admin",
success : function(data) {
console.log(data);
if (data == "1") {
swal(
'Correcto!',
'Grupo agregado correctamente!',
'success'
).then(function () {
$('#add').modal('close');
document.location.href = "test#tab1";
})
}else if (data == "2") {
swal(
'Error!',
'Ha ocurrido un error, contacte al administrador!',
'error'
)
}else if (data == "0") {
swal(
'Error!',
'Todos los campos son obligatorios!',
'error'
)
}
}
});
I want to reload the page (the same URL), but with a different #
(hash or fragment). The problem I have is on the line:
document.location.href = "test#tab1";
Since it does not work, that is, it does not reload the page in the #tab1
section.
If I remove #tab1
it works normal, but it is at the top of the page and does not go to that element.
How could I solve this?