0
Hello I have a field on the site called search service, and would like to make an ajax call to redirect to another page.
<li>
<form class="navbar-form full-width">
<div class="form-group">
<input type="text" class="form-control" placeholder="Buscar Atendimento..." />
<button id="Busca" type="submit" class="btn btn-search"><i class="fa fa-search"></i></button>
</div>
</form>
</li>
Function:
function FiltrarRelatorio() {
var Busca = $('#Busca').val();
if (remover === true) {
Busca = 0;
}
$.ajax({
type: "post",
url: '@Url.Action("Agendamentos")',
data: {
Busca: Busca
},
success: function (data) {
window.location.href = data;
},
error: function () {
},
complete: function () {
//location.reload();
}
});
}
What am I doing wrong? When I click on the button it just reloads the source page instead of going to the destination page.
Where does this variable come from
remover
inif (remover === true) {
and why the variableBusca
must be equal to0
? Where you are calling the functionFiltrarRelatorio()
to execute the Ajax?– Sam
Because you’re getting the value of the button in
$('#Busca').val()
? You shouldn’t take the input value?– Sam