开发者

Symfony: trouble with JS activated image

I have a script that switches background image on hover:

$('div#example').hover(functi开发者_C百科on(){
  $(this).css('background',"url('images/bg_2.png') no-repeat bottom");
});

I am using a WAMP development environment, and this works fine if the url I use is either:

localhost/example/web -or- localhost/example/web/frontend_dev.php

However, if I use localhost/example/web/frontend_dev.php/, (added slash at end) the image no longer loads? What is going on?

Thanks.

Additional info:

  • For the 'effected' case-scenario, all images set through CSS work fine (only images referenced through JS have problems). Favicon Does NOT load either, for some reason.
  • localhost/web/ works fine


Based on the url's you are providing (localhost/example/web, localhost/example/web/frontend_dev.php, etc) it seems you are not using a Virtual Hosts setup as described in here http://www.symfony-project.org/gentle-introduction/1_4/en/03-Running-Symfony (see 'Web Server Configuration' section)

You will then be able to reference the image using /images/bg_2.png

There are a number of other reasons why you should use a Virtual Host setup including security (only files in web/ need to be web accessible) and ease of deployment (ie, using urls like localhost/example/web wont work when deployed to another server unless you mimic your local setup exactly)


What happens if you put a slah before the images folder, such as:

/images/bg_2.png

It wont when you're on the URL: localhost/example/web/frontend_dev.php/

As it'll be looking for the path: localhost/example/web/frontend_dev.php/images, which is wrong as I'm guessing your images are in localhost/example/web/images

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜