We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49864
    • 4 Posts
    Hi guys,

    I have a very odd problem. I recently moved my site to a new server. Following the modx instructions I did not have any problems, and the webpage worked fine.

    I am using some chunks in the header of my template. In one of the chunks I am loading "jquery"
    <script type="text/javascript" src="../jquery.min.js"></script>

    Whenever I clear the cache, jQuery is loaded and everything works fine! However, when reloading or changing to another page, the row where I load jQuery is deleted and does not appear in the browsers source code. This problem is repeatable, it works fine after clearing the cache (either in the manager, or manually by deleting the content of the core/cache folder).

    I can change anything else in the chunk, I have also some other javascripts loading in that chunk. No problems! Everything that I change will appear in the browser sourcecode. I added a commented line before and after the jQuery command. Even these comments will appear in the sourcecode of the browser, but there is a blank line instead of jQuery between them.

    This problem does seem to appear only for this template. I am using a second template, where the loading of jQuery works fine.

    I checked "modx_site_htmlsnippets" in the database and the sourcecode is ok there. Even after reloading and showing the wrong content in my browser, the database entry is correct.

    I have also tried to re-run the setup. No success.

    I used the same source to create another website. On that copy I don't have this problem.

    Gettin' crazy!!

    Any ideas?

    Cheers
    Marco

    modx version: 2.3.2
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Can you post the part of the template with the chunk tag, and post the contents of the chunk?
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 49864
        • 4 Posts
        Hi, yes sure:


        Chunk-Tag in the template:
        [[$sinaki.menu-head-append]]


        This is the chunk:
        <!-- <script src="[[++assets_url]]components/boilerx/js/vendor/jquery-[[++bx.jquery_version]].min.js" type="text/javascript"></script> -->
        <script src="//ajax.googleapis.com/ajax/libs/jquery/[[++bx.jquery_version]]/jquery.min.js"></script>
        
        <script type="text/javascript">
        $(document).ready(function(){
        	//hide the all of the element with class msg_body
        	$(".msg_body").hide();
        	//toggle the componenet with class msg_body
        	$(".msg_head_orange").toggle(function(){
        		$(this).next(".msg_body").slideDown(300);
        		}, function(){
        		$(this).next(".msg_body").slideUp(300);
        	});
        
        	$(".msg_head_green").toggle(function(){
        		$(this).next(".msg_body").slideDown(200);
        		}, function(){
        		$(this).next(".msg_body").slideUp(300);
        	});	
        });
        </script>


        It is funny that even the commented script in the first row will disappear. Also the external request from googleapis. The bx.jquery_version is 1.8.3 and the file exists.

        It will not load, even if I put it in one of the other header-chunks. The other script does appear att all times.

        Cheers
        Marco
          • 3749
          • 24,544 Posts
          Have you tried this?

          [[!$sinaki.menu-head-append]]
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            The only thing that comes to mind is something is removing the lines after the page is generated but before it is sent by the web server back to the requesting browser. A plugin, perhaps? Or perhaps some kind of security setting on the server that does not permit javascript sources from external URLs? Or perhaps even some kind of security setting on the client's machine or LAN router/firewall to prevent javascript URLs from third-party URLs?
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 10208 ☆ A M B ☆
              • 1,780 Posts
              Stab in the dark, but what is before that chunk? A mistake I made before a jquery script recently solved a similar issue, it may be worth inspecting the surrounding code.

                Frogabog- MODX Websites in Portland Oregon
                "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                Having server issues? These guys have MODX Hosting perfected - SkyToaster
                • 49864
                • 4 Posts
                Quote from: sottwell at Feb 11, 2015, 06:41 PM
                The only thing that comes to mind is something is removing the lines after the page is generated but before it is sent by the web server back to the requesting browser. A plugin, perhaps? Or perhaps some kind of security setting on the server that does not permit javascript sources from external URLs? Or perhaps even some kind of security setting on the client's machine or LAN router/firewall to prevent javascript URLs from third-party URLs?

                I doubt that, because it works fine with a different template. I also checked local software, antivirus, etc, but nothing seems to block the browser. This issue appears on different computers and my phone.
                Also I am loading other external javascript sources as well which do not cause this problem. Though this one is stored on my server.



                Quote from: frogabog at Feb 11, 2015, 07:56 PM
                Stab in the dark, but what is before that chunk? A mistake I made before a jquery script recently solved a similar issue, it may be worth inspecting the surrounding code.

                I did check the code again. I am using chunks to open and close the header, but I didn't find anything odd. It also works well with a different template.

                Quote from: BobRay at Feb 11, 2015, 05:21 PM
                Have you tried this?

                [[!$sinaki.menu-head-append]]

                I tried this code and I seems it fixed the problem. So far I couldn't reproduce it. I still wonder, because I cleared the cache several times before.

                Thanks for the replies! I will let you know if the problem re-appears.
                  • 49864
                  • 4 Posts
                  Hi,

                  unfortunately I was announcing to quickly that the above code solved my problem.

                  [[!$sinaki.menu-head-append]]


                  The problem still exists:

                  (1) The text row where I load jQuery (either local or from external) will be removed.
                  (2) I changed the slideUp and slideDown times in my script, but these updates are not shown in the browser.

                  I thought this code is forcing not to cache the chunk. It seems that not only a cached version of the chunk is used (2), but also content of the chunk is removed (1).

                  I did run an update to Revolution 2.3.3. This didn't solve the problem.