Hommy De Jesús
Hommy De Jesús

Reputation: 21

Problems trying to import a .js file in codeigniter

Hello friends I'm having problems trying to use some functions that I have in two .js file. I already tried putting base_url(); and the location of the file, I also added the 'url' in the config.php

<script type="text/javascript" src="<?php echo base_url();?>js/pdf.js" ></script>
<script type="text/javascript" src="<?php echo base_url();?>js/pdf.worker.js" ></script>

I have the file in folder called: js

ERROR I GET ON THE GOOGLE CHROME CONSOLE:

GET http://[::1]/registro/js/pdf.worker.js net::ERR_ABORTED

EDITED CONSOLE ERROR enter image description here

Upvotes: 1

Views: 485

Answers (2)

Shiva Manhar
Shiva Manhar

Reputation: 703

Edit /application/config/config.php file
Remove this line
$config['base_url'] = '';

Rdd this code in config.php file

$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;

Edit /application/config/autoload.php file.

$autoload['helper'] = array('url');

Upvotes: 0

DFriend
DFriend

Reputation: 8964

The request http://[::1] points to a common error - $config['base_url'] MUST be set correctly. An empty string will not work. The entry in /application/config/config.php should look something like this.

 $config['base_url'] = "http://example.com/";

Note the protocol http:// and a trailing / must be included.

Upvotes: 1

Related Questions