Welcome to WebmasterWorld Guest from 23.20.223.88

Forum Moderators: open

Message Too Old, No Replies

Javascript broken after changing subdomains

Jquery not responding to events

     
3:01 pm on Jun 24, 2011 (gmt 0)

5+ Year Member



Greetings,
I have run into a frustrating problem that I can not seem to figure out. We have a page on a development platform that is working fine. We use jQuery to show/hide divs based on user interaction. We decided it was time to move it to our test platform so that in house people could test. This is when the problem began. jQuery no longer responds to certain events occuring. We have one event that fires on page load, and several events that happen when something is clicked. Note that the ONLY thing we did was copy the needed files from development to test subdomains on our internal web server.

The other puzzling thing is we do have a nav system in place for the website that uses jQuery as well and it does not seem to have a problem.

Below are the libraries we are currently loading as well as the events that are failing. Note that I placed the alert into the top of the script to see if it would fire, and it did not.


<script type="text/javascript" src="/modules/mod_superfishmenu/tmpl/js/jquery.js"></script> 
<script type="text/javascript" src="/components/com_products/views/product/tmpl/js/motionpack.js"></script>
<script type="text/javascript" src="/media/system/js/mootools.js"></script>
<script type="text/javascript" src="http://test.example.com/modules/mod_ninja_shadowbox/ninja_shadowbox/js/lib/jquery.js"></script>
<script type="text/javascript" src="http://test.example.com/modules/mod_ninja_shadowbox/ninja_shadowbox/js/adapter/shadowbox-jquery.js"></script>
<script type="text/javascript" src="http://test.example.com/modules/mod_ninja_shadowbox/ninja_shadowbox/js/shadowbox.js"></script>
<script type="text/javascript" src="http://test.example.com/modules/mod_superfishmenu/tmpl/js/jquery.event.hover.js"></script>
<script type="text/javascript" src="http://test.example.com/modules/mod_superfishmenu/tmpl/js/superfish.js"></script>
<script type="text/javascript" src="/templates/test/js/tab.js"></script>
<script type="text/javascript">

Shadowbox.loadSkin("classic", "http://test.example.com/modules/mod_ninja_shadowbox/ninja_shadowbox/js/skin");
Shadowbox.loadLanguage("en", "http://test.example.com/modules/mod_ninja_shadowbox/ninja_shadowbox/js/lang");
Shadowbox.loadPlayer(["img","swf","flv","qt","wmp","iframe","html"], "http://test.example.com/modules/mod_ninja_shadowbox/ninja_shadowbox/js/player");
jQuery.noConflict(); jQuery(document).ready(function(){
window.onload = Shadowbox.init;
});
jQuery.noConflict();
jQuery(function($){ $("ul.sf-menu").superfish({hoverClass:'sfHover', pathClass:'active', pathLevels:0, delay:800, animation:{opacity:'show'}, speed:'def', autoArrows:1, dropShadows:1}) });
jQuery.event.special.hover.delay = 100;
jQuery.event.special.hover.speed = 100;

</script>


*******THIS PART IS IN THE BODY SECTION****************
<script type="text/javascript">
jQuery(document).ready(function() {
alert("page loaded");
jQuery(".oneU").hide();
jQuery(".twoU").hide();
jQuery(".threeU").hide();
jQuery(".fourU").hide();
jQuery(".fiveU").hide();
jQuery(".sixU").hide();
jQuery(".Custom").hide();
//toggle the componenet with class msg_body
jQuery(".oneUheading").click(function()
{
jQuery(".twoU").hide();
jQuery(".threeU").hide();
jQuery(".fourU").hide();
jQuery(".fiveU").hide();
jQuery(".sixU").hide();
jQuery(".Custom").hide();
jQuery(".oneU").slideToggle("slow");
});
//toggle the componenet with class msg_body
jQuery(".twoUheading").click(function()
{
//alert(this);
jQuery(".oneU").hide();
jQuery(".threeU").hide();
jQuery(".fourU").hide();
jQuery(".fiveU").hide();
jQuery(".sixU").hide();
jQuery(".Custom").hide();
jQuery(".twoU").slideToggle("slow");

});
//toggle the componenet with class msg_body
jQuery(".threeUheading").click(function()
{
//alert(this);
jQuery(".oneU").hide();
jQuery(".twoU").hide();
jQuery(".fourU").hide();
jQuery(".fiveU").hide();
jQuery(".sixU").hide();
jQuery(".Custom").hide();
jQuery(".threeU").slideToggle("slow");
});
//toggle the componenet with class msg_body
jQuery(".fourUheading").click(function()
{
//alert(this);
jQuery(".oneU").hide();
jQuery(".twoU").hide();
jQuery(".threeU").hide();
jQuery(".fiveU").hide();
jQuery(".sixU").hide();
jQuery(".Custom").hide();
jQuery(".fourU").slideToggle("slow");
});
//toggle the componenet with class msg_body
jQuery(".Custheading").click(function()
{
//alert(this);
jQuery(".oneU").hide();
jQuery(".twoU").hide();
jQuery(".threeU").hide();
jQuery(".fourU").hide();
jQuery(".fiveU").hide();
jQuery(".sixU").hide();
jQuery(".Custom").slideToggle("slow");
});
//toggle the componenet with class msg_body
jQuery(".fiveUheading").click(function()
{
//alert(this);
jQuery(".oneU").hide();
jQuery(".twoU").hide();
jQuery(".threeU").hide();
jQuery(".fourU").hide();
jQuery(".sixU").hide();
jQuery(".Custom").hide();
jQuery(".fiveU").slideToggle("slow");
});
//toggle the componenet with class msg_body
jQuery(".sixUheading").click(function()
{
//alert(this);
jQuery(".oneU").hide();
jQuery(".twoU").hide();
jQuery(".threeU").hide();
jQuery(".fourU").hide();
jQuery(".Custom").hide();
jQuery(".fiveU").hide();
jQuery(".sixU").slideToggle("slow");
});
});
</script>


Any suggestions would be appreciated.
3:28 pm on Jun 24, 2011 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Any reason why you have the first 3 paths as root-relative (eg. "/modules/mod_superfishmenu/tmpl/js/jquery.js") and the rest as absolute (eg. "http://test.example.com/modules/mod_ninja_shadowbox/ninja_shadowbox/js/lib/jquery.js")

Are you sure all these scripts are found?

Is the test subdomain serving JS files any differently, ie. wrong headers?
3:38 pm on Jun 24, 2011 (gmt 0)

5+ Year Member



I have clicked through them in chrome's source view and all have been found. This is joomla so some of the paths are entered by plugins as they are installed, others I have added in (motionpack.js is the library that should be responding to these requests but is not)
3:23 pm on Jun 27, 2011 (gmt 0)

5+ Year Member



An update on this. Still not working. It just does not seem to be loading the external JS. Going to try placing it inside the document to see if that will work. I have viewed headers returned from both working and non-working pages and they are the same. It does appear to be loading the external JS properly, but the code just does not do anything on the test page.
4:34 pm on Jun 27, 2011 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Just to confirm... the JS files themselves are returning the Content-Type header 'text/javascript' (regardless of the headers of the actual page)?
4:37 pm on Jun 27, 2011 (gmt 0)

5+ Year Member



Where would I confirm this? I am using both Chrome as well as firefox with firebug.
4:44 pm on Jun 27, 2011 (gmt 0)

5+ Year Member



Ok, I think I got it. The two pages are different. If I look in firebug at the headers for the js file, I see NO content-type returned (this is the WORKING page)

If I look at the headers on the non-working page, it shows:
Content-Typeapplication/x-javascript
 

Featured Threads

Hot Threads This Week

Hot Threads This Month