I have read all the topics "Including Javascript files in CodeIgniter" but these don't work for me! I reduced my problem to the following code.
I work with WAMP and I copied Codeigniter in c:\wamp\www\codeigniter folder.
In c:\wamp\www\codeigniter\application\controlers\ I have a file mnd3c_test.php that contains:
<?php
class mnd3c_test extends CI_Controller {
public function __construct()
{parent::__construct();}
public function test()
{$this->load->view('mnd3v/mnd3v_test.php'); }
}
In c:\wamp\www\codeigniter\application\view\mnd3v\ I have a file mnd3v_test.php that contains:
<html>
<head>
<script type="text/javascript" src="mnd3js.js" ></script>
</head>
<body>
<h3 onclick="fsort()">Click on me to see alert message</h3>
</body>
</html>
In c:\wamp\www\codeigniter\application\view\mnd3v\ I also have a file mnd3js.js that contains:
function fsort()
{ alert ("fsort"); }
I have set in config.php:
$config['base_url'] = 'http://localhost/codeigniter/';
I load my page in Internet Explorer or Google Chrome with:
http://localhost/codeigniter/index.php/mnd3c_test/test
and when I click on "Click on me to see alert message" nothing happens (In IE I have a "Error on page" message). I have tried to put in src atribute all kind of values, like mnd3v/mnd3js.js or localhost/application/views/mnd3v/mnd3js.js but nothing happend.
I would like to see the alert message. Can anybody help me?
index.phpfile located? If yoursrcURL is simplymnd3js.js, then it would need to be located in same directory as yourindex.php.srcpath is simplymnd3js.js, then it would need to be located in same directory as yourindex.php. What troubleshooting have you performed? Have you inspected your JavaScript console errors? Are you sure you spelled the file name correctly?mnd3js.jsin many folders" ~ If you insist on programming by "trial & error" rather than by logic & knowledge, you might as well copy the file into all folders at once. If it works, delete them one by one until it breaks again. Hopefully, you'll learn something along the way.