How can I stay on the same page with ajax?
my ajax is
$('#add-user').click(function() {
$.ajax({
type: "GET",
url: "/evaluacion/usuariosSeleccionados",
data: {
fact: JSON.stringify(localStorage.getItem("evaluacion")),
seleccionados: JSON.stringify(yourArray)
},
contentType: "application/json; charset=utf-8",
dataType: "text",
success: function(data) {
document.open("text/html", "replace");
document.write(data);
document.close();
window.location.href="/evaluacion/agregarUsuarios"// esto hago para que se quede en la misma pagina
},
error: function(err) {
var msg = 'Status: ' + err.status + ': ' + err.responseText;
}
});
and my link is
a(href="" id='add-user' class='btn btn-primary') agregar usuarios
window.location.href="/ evaluation / addUsers" // this I do for stay on the same page
it's okay to use window.location.href ???