ajaxian
(Dorioajax)
1
Hy All
First of all, I wish for all of you an happy new year …
I’ve the quite the same problem depicted in this post.
In fact sometimes my javascript files are loaded twice and sometimes not.
It seems it comes from the Url (two kinds of Url lead to those two kinds of behaviors)
I try to do URL SEO friendly then I have Url like this
http://localhost/mySite/xxx => Then no problem
http://localhost/mySite/xxx/yyy => Then my scripts are loaded twice.
It seems strange because jquery library, loaded with registerCoreScript is never loaded twice.
When all things work well I have, for a javascript file, with Firebug, 2 "404 CHttpException"
Do you know what is the problem ?
Thanks
ajaxian
(Dorioajax)
2
To be more precise:
When Url is like
http://localhost/mySite/xxx
Then the Loaded javascript is found in
http://localhost/mySite/js/file.js
And it works well.
When Url is like
http://localhost/mySite/xxx/yyy
Then the javascript file is searched in
http://localhost/mySite/xxx/js/file.js
and for sure it fails
How do you include such files? Could you show the links here?
I meant the PHP generating the inclusion
ajaxian
(Dorioajax)
4
OK I solve the problem
It was mainly due to Champain.
I did like this:
$cs->registerScriptFile('/js/file.js',CClientScript::POS_END)
And it works well for Url localhost/mySite/xxx but not for localhost/mySite/xxx/yyy
Whereas this works for both
$cs->registerScriptFile(Yii::app()->request->baseUrl.'/js/file.js',CClientScript::POS_END)
hiips !!
(thank you Antonio for your reply)
I knew was something like that… I had the same problem at the beginning ![:)](http://www.yiiframework.com/forum/public/style_emoticons/default/smile.gif)
Please CCO me some champaing… otherwise fax it… ![;)](http://www.yiiframework.com/forum/public/style_emoticons/default/wink.gif)