Welcome Guest, Not a member yet? Register   Sign In
Javascripts,css and images not present while loading the same page using different controller from the link in current
#1

[eluser]Sanjabs[/eluser]
Hi I am new to this codeIgniter framework.
I made a controller to display my sample page with links,I used Ajax for creating dynamic menus. One of the menu has a URI to different controller which loads the same view. But when the menu clicked the page is displayed with missing images, no javascripts and no css also.

Could someone tell me whats happening here???
#2

[eluser]jedd[/eluser]
Hi Sanjabs, and welcome to the CI forums.

You could post your two controllers, but I suspect you'll probably spot the cause of the error when you look at the page-source of the working page, and compare it with the page-source of the non-working one.

Actually, if you can post the HEAD sections of each page-source - that will help too.
#3

[eluser]Sanjabs[/eluser]
class Educates extends Controller {

function index()
{
$this->load->database();
$this->load->view('Testpage');
}
}//Working Controller

class Institutions extends Controller {

function other()
{
$this->load->database();
$this->load->view('Institution');
}
}//Controller that is displaying same page with missing components

Link is used is "institutions/other"

I recently checked with the following changes:
class Institutions extends Controller {

function index()
{
$this->load->database();
$this->load->view('Institution');
}
}
and set the link to 'institutions' only and it worked

Cant we use other methods other than index inside a controller to load a view....?
#4

[eluser]jedd[/eluser]
Quote:Cant we use other methods other than index inside a controller to load a view....?

You can absolutely load a view from any method in your controllers.


The information above isn't much to go on - the HEAD sections of your working and non-working pages - did you look at those yet? I suspect it's a simple PATHing issue within your view file(s).

Post the section of your view(s) that load the CSS and images.
#5

[eluser]tomcode[/eluser]
Sounds like You don' use absolute URL's for Your assets, in this case everthing shows up on only in Your home page.
#6

[eluser]Sanjabs[/eluser]
Here is my part of view code which imports the necessary files for the view page:

javascript folder is in my root folder and educate.css and menu.js are also on root folder.

<link href="educate.css" media="all" rel="stylesheet" type="text/css">
[removed][removed]
[removed][removed]

The page loads with an error: Object Expected...
So whats the problem over here?
#7

[eluser]rogierb[/eluser]
Hi,

you should use the base_url() when referencing to images and/or css etc.

in your case:
<link href=“<?php echo base_url()?>educate.css” media=“all” rel=“stylesheet” type=“text/css”>
#8

[eluser]Sanjabs[/eluser]
Thanks, it worked........




Theme © iAndrew 2016 - Forum software by © MyBB