Datatable Tricks
=> In datatable redirect baseurl when session is expired:
- In datable.js file write following code:
"data": function (d) {
$.getJSON('contacts/ajaxData',myData, function (json) {
if (json.expired == '1') {
window.location = BASE_URL;
}
});
return $.extend(d, myData);
},
In, $.getJSON you have to pass controller name/method name (ex. contacts/ajaxData)
- In controller write following code:
if ($this->input->is_ajax_request()){
echo json_encode(array("expired" => "1"));exit;
}
- In datable.js file write following code:
"data": function (d) {
$.getJSON('contacts/ajaxData',myData, function (json) {
if (json.expired == '1') {
window.location = BASE_URL;
}
});
return $.extend(d, myData);
},
In, $.getJSON you have to pass controller name/method name (ex. contacts/ajaxData)
- In controller write following code:
if ($this->input->is_ajax_request()){
echo json_encode(array("expired" => "1"));exit;
}
Comments
Post a Comment