failed to load jquery.cookie - 404 error

I have an extenstion that loads jquery.cookie.js file. It works fine on my local machine, but it doesn’t work in production. It says: “Failed to load resource: the server responded with a status of 404 (CHttpException)” when trying to load jquery.cookie.js file.

I have checked that this file loads successfully into assets folder, but it for some reason cannot be loaded. I do not know where to look at.

These are line that register js:




$path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';

$assetUrl = Yii::app()->assetManager->publish($path, false, -1, YII_DEBUG);

Yii::app()->clientScript->registerScriptFile($assetUrl.'/jquery.jstree.js');

Yii::app()->clientScript->registerScriptFile($assetUrl.'/_lib/jquery.cookie.js');

Yii::app()->clientScript->registerScriptFile($assetUrl.'/_lib/jquery.hotkeys.js');



There are problems only with jquery.cookie.js file.

I even tried to put jquery.cookie.js into “js” folder, it works on localhost, but doesn’t work on server.

I am quite new in Yii and this is very strange error, I cannot understand even where to look at…

I thought maybe it is wrong to register jquery.cookie.js, as it is in yii core? But if I remove registerScrhiptFile than I am getting "jQuery cookie plugin not included." in "jquery.jstree.js" (that is loaded by extension).

You can see this error here: http://www.taviemmatiem.lv/backend/categories/index

Really, need your help.

:::

The strange thing is that if I change jquery.cookie.js to jquery.coo.js that it works fine. So I see that here is something with yii core.

R.

Have you confirmed that the file is being published into the directory by browsing it over FTP?

you know why because your path to the assets folder is different on server

here try this




Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/js/_lib/jquery.cookie.js');

shoud work

The file is published in assets folder.

Path to asset folder is correct on server. I echoed it and checked - the path is correct. All other assets are loaded (also within this widget), for example,

$assetUrl = Yii::app()->assetManager->publish($path, false, -1, YII_DEBUG);

Yii::app()->clientScript->registerScriptFile($assetUrl.’/jquery.jstree.js’);

or

Yii::app()->clientScript->registerScriptFile($assetUrl.’/_lib/jquery.hotkeys.js’);

And see above - I have edited my post - if I change file name from jquery.cookie.js to jquery.coo.js than it works. So it is very strange error.

weird never seen this kind problem before anyway you got it sorted

it’s because of mod_security. it is active on your server and denies the access to that url because it contains the word cookie.

You can try and kill the mod_security from the htaccess file.