’requestedPageType’ is a url parameter in my application. Whenever the user logs in, he is presented with the dashboard. the dashboard takes the requestedPageType value and jquery load()’s the correct view. So if ‘requestedPageType=userProfile’, the userProfile view in CodeIgniter will be loaded and appended using jquery. what is another way I can load individual pages into dashboard.php based off what page the user is trying to view?
Below is an example of the code I have so far:
if ($(document).getUrlParam("requestedPageType") === 'startpage') {
// loads the wall when the user firsts logs in
jQuery('#main').load('<?=base_url()?>index.php/routers/startpage');
} else if ($(document).getUrlParam('requestedPageType') === 'wall_1') {
var ide2 = $(document).getUrlParam("churchid");
// loads wall_1
$('#main').load('<?=base_url()?>index.php/routers/wall_1',{id:ide2});
$('#logoTd').remove();
} else if ($(document).getUrlParam("requestedPageType") === 'userProfiles') {
// loads the wall when the user firsts logs in
var ide = $(document).getUrlParam("id");
jQuery('#main').load('<?=base_url()?>index.php/routers/userProfiles',{id:ide});
} else if ($(document).getUrlParam("requestedPageType") === 'addEditUserInfo') {
var ide1 = $(document).getUrlParam("id");
jQuery('#main').load('<?=base_url()?>index.php/routers/addEditUserInfo', {id:ide1});
} if ($(document).getUrlParam("loggingStatus") === 'loggedIn') {
$("#showUserBlink").fadeIn(1000); // show and blink when user first logs in
}
Do the redirection and stuff in PHP. You’re paying the cost of sending a new request anyways, just forward the parameters to a PHP script which can then decide what to show the user, be it with a redirect or an include.
The way you’re proposing right now might have problems if the user modifies the parameters to, say, edit the user info of whoever’s id is 1 (probably you!). If you code the server side properly to detect such behavior then you’ve already got all the logic you need server side, and there’s no need to use javascript for it.