When JavaScript is executed the Url is replaced by "url: '/'," so it is impossible for me to return the values from my controller to the script
Does anyone know what is causing this problem?
Code:
<script type="text/javascript">
$(document).ready(function () {
$('#logbtn').click(function (e) {
var pin = $('#Pin').val();
console.log(pin);
$.ajax({
type: "POST",
data: {Pin: pin},
url: '@Url.Action("Login", "Ttraslados")',
dataType: "json",
success: (function (r) {
console.log(r.Message);
switch (r.Message) {
case "Error1": swal("¡Cuidado!", "Este campo no puede estar vacio y el PIN solo deben ser numeros", "success"); break;
case "Error2": swal("Oops!", "El usuario es incorrecto o inexistente", "error"); break;
default: swal("Oops", "Error inesperado", "error");
}
}),
error:(function () {
swal("Oops", "Hubo un error", "error" );
})
});
});
});
</script>
and this is the code when it is executed
$(document).ready(function () {
$('#logbtn').click(function (e) {
var pin = $('#Pin').val();
console.log(pin);
$.ajax({
type: "POST",
data: {Pin: pin},
url: '/',
dataType: "json",
success: (function (r) {
console.log(r.Message);
switch (r.Message) {
case "Error1": swal("¡Cuidado!", "Este campo no puede estar vacio y el PIN solo deben ser numeros", "success"); break;
case "Error2": swal("Oops!", "El usuario es incorrecto o inexistente", "error"); break;
default: swal("Oops", "Error inesperado", "error");
}
}),
error:(function () {
swal("Oops", "Hubo un error", "error" );
})
});
});
});
the variable "url" stores only one slash.
copy this script from another that I had already made it work correctly