-1
Good afternoon, I am sending a value via AJAX/Jquery that triggers me the controller notifications index function. When I receive a certain value, I want the function to direct me to another page. It turns out that when I receive this value, the function does not redirect me to another page but prints me that page on the console. How do I direct me to the page?
The code I’m using is as follows::
$( document ).ready(function() {
$('#notifications').click(function(){
$.ajax({
url: '<?=base_url("notificacoes")?>',
type: 'POST',
data: {
key: 'olá'
},
success: function(data) {
console.log(data);
}
});
});
});
Controller :
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Notificacoes extends CI_Controller {
public function index(){
return $this->load->view('norm');
}
}
Knob :
<button class="btn btn-secondary pr-2" type="button" id="notifications" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-bell" aria-hidden="true"></i>
<span class="badge">0</span>
</button>
The
data
returns the address of a page? If so, just uselocation.href=data
– Sam