We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39707
    • 3 Posts
    Hello everybody !

    I try to make an AJAX call following this example : http://wiki.modxcms.com/index.php/Use_AJAX_with_modxAPI ("The Full MODx solution").

    The problem I'm facing is that when I'm calling the resource which contains the JavaScript, it isn't loading it at all. In fact, when I look at the source code, the ModX tag isn't interpreted : I'm still getting :
    <script type="text/javascript" src="[[~63]]"></script>


    The resource number 63 which contains the JavaScript has a template set to "empty" and a content type set to "javascript". I'm using JQuery, the script is as follow :
    $(function() {
    	alert("ok");
    });


    Thanks in advance for your help !

    This question has been answered by BobRay. See the first response.

    [ed. note: jeremy-p last edited this post 11 years, 11 months ago.]
    • discuss.answer
      • 3749
      • 24,544 Posts
      The line with regClientStartupScript() may be executing after the page tags are parsed. You may have to use $modx->makeUrl(63) to set the URL in the code that calls regClientStartupScript().


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 39707
        • 3 Posts
        Thank you very much BobRay, works like a charm !

        By the way, thanks for the great help you provide with your site Bob's Guides ! I learnt a lot about ModX wink [ed. note: jeremy-p last edited this post 11 years, 11 months ago.]