jQuery ajax success not work in codeigniter
- by softboxkid
I had a problem with ajax. The trick is, when user click on the top hyperlink, it will send the link id through onclick=getChildMenuLink(str). Then from getChildMenuLink(str) function, it will send the str to the controller (to set the session) thru ajax. here is the code.
html code
<a href="http://localhost/ejournal/index.php/sysconfig" onclick="getChildMenuLink(1)">Administrator</a>
<a href="http://localhost/ejournal/index.php/welcome" onclick="getChildMenuLink(22)">Home</a>
jquery ajax
function getChildMenuLink(str) {
'use strict';
$.ajax({
type: 'POST',
url: "http://localhost/ejournal/index.php/sysconfig/getLink/" + str,
success: function () {} // End of success function of ajax form
}); // End of ajax call
//alert(document.URL);
}
codeigniter controller
function getLink($id='')
{
$this->session->unset_userdata('parentLink');
$this->session->set_userdata('parentLink',$id);
}
if i uncomment the alert() function on that script, it work. the PHP session is properly set. please help me