I'm trying to redirect a user after a form submission with AJAX. I tried using window.location.assign, window.location.href and both didn't work.
When this function is triggered i receive the following text in Google Chrome console (This line refer to console.log(response), response is the url i get back from funcaoCla.php):
../usuario/cla?claatualizado
My JS function:
function funcaoCla(){
var nomeCla = $("#nomeDoCla").val();
var tagCla = $("#tagDoCla").val();
var corDoCla = $("#corDoCla").val();
if (verificaCla()){
$.ajax({
async: false,
url: '../modulos/funcaoCla.php',
type: 'post',
data: {'cadastrar_cla':'cadastrar_cla', 'nomeCla' : nomeCla, 'tagCla' : tagCla, 'corCla' : corDoCla},
success: function(response){
console.log(response)
window.location.assign(response)
},
error: function(response){
console.log("ERRO")
console.log(response)
alert("Algo pode ter dado errado, atualize a pagina e tente novamente!")
}
})
}else {
return false;
}
}