Support » Plugin: Advanced AJAX Page Loader » [Plugin: Advanced AJAX Page Loader] AAPL_warnings not defined

  • Resolved bitoolean


    The following line in advanced-ajax-page-loader.php has broken the plugin for some time now… it hasn’t been working for me without this fix, while new versions keep coming up…

    At line 215, replace all double quotes with single quotes and vice-versa, because the value returned by the PHP snippet (the URL path to jquery.js) is already enclosed in double quotes which otherwise don’t get escaped and break the code and the functionality of the plugin completely.

    This is what the line should be:
    document.write('<scr' + 'ipt type="text/javascript" src="<?php echo plugins_url( "jquery.js" , __FILE__ );?>"></scr' + 'ipt>');

    Because of this error, the inline script in the head of pages doesn’t get executed and “variable not defined” errors come up, while ajax functionality doesn’t work.

Viewing 15 replies - 1 through 15 (of 19 total)
  • I don’t need the jQuery check / loader / initializer, so I simply comment out the whole initJQuery() function definition and the following call to that function (within the PHP file).

    I also remove everything from the jQuery document load event handler in ajax-page-loader.js except the call to AAPL_loadPageInit(“”);

    This fixes the plugin version 2.5.9, but not the latest version (2.5.12).

    The website using it can be found here.

    Plugin Author Dean Williams


    It sounds like you have a problem with your wordpress install… Why would the plugin path coming from:

    <?php echo plugins_url( “jquery.js” , __FILE__ );?>

    return any quotes?!?!?! It is a PATH.

    I have actually changed this in the latest version to use jQuery instead so maybe this will help in your case, I would check your installation path and made sure you did not include any quotes.

    Let me know if this works.

    I think I did a mistake by saying that WP returns a path enclosed in double quotes, that wouldn’t make much sense indeed. I was just confused when I examined the source code of the live page. That string appeared to be very wrongly escaped and thus breaking the entire script processing in my case (it invalidated the HTML), even with the jQuery check being disabled.

    I don’t even know why a jQuery is included with AAPL, and why it overrides the default WP path. I don’t understand, because I’ve already overridden the default WP path with that of the one hosted by Google (and I specify a major version only which acts like a wildcard on the minor version, always getting the latest one). So AAPL should probably check the jQuery version already loaded and then decide whether it should use its own one? (which may be older!). I’m new to web programming, and I’m just learning PHP and Javascript etc., so I’m not giving advice, I’m just asking. Maybe letting the user know he needs to update his jQuery.js would be enough. Now I have two useless rather large jQuery libraries sitting on the server…

    Anyway, I had disabled the plugin, deleted the plugin folder and uploaded version 2.5.12, then enabled it again, and it didn’t work at all, so I just reverted to 2.5.9. I update the plugin manually just to make sure I don’t lose my settings, and because I have to (it’s free hosting, the server limits max. execution time of PHP scripts to 10 seconds only).

    I’ll try the latest version, revision 13, and return with results.

    Is this only happening to me? Check this at (clicking on the post excerpts’ titles doesn’t AJAX-load content), so the syntax error below breaks script execution (I was wrong again saying it invalidates HTML, but because it deals with HTML code generation):

    if (! jQueryScriptOutputted) {
      //only output the script once..
      jQueryScriptOutputted = true;
      //output the jquery script
      document.write("<scr" + "ipt type='text/javascript' src=""></scr" + "ipt>");
     <strong>Uncaught SyntaxError: Unexpected identifier</strong>

    You see, there is a double-quoted string (the jQuery path specified as the value for the SRC attribute) inside another double-quoted string.

    It seems you’ve published revision 14 in the meantime. I’ll check that too a little later.

    There’s also again the “AAPL_wanings is not defined” within the jQuery(document).ready at line:
    if (AAPL_warnings == true)

    Plugin Author Dean Williams


    hey bitoolean

    right okay I understand,
    the reason behind the jquery check is that some versions of wordpress do not come with jquery, others do come with it, and then some plugins include jquery themselves and either override the wordpress jquery (sometimes with a outdated version) and etc etc.

    So because of this mess of conflict/missing/included under another namespace etc, I created the jqueryinit function which basically checks if jquery is around, and if so it will NOT DO ANYTHING.

    But if jquery isnt around it will try and include it (and if its outdated it will try override it/show an error).

    I killed my plugin so please try 2.5.15 in a moment when its released.

    Plugin Author Dean Williams


    BTW – if you want to disable the jQuery check there is an option in the admin panel called “Enable jQuery check.”

    Using revision 16, the errors I mentioned above are still present.
    You seem to have updated that code, but you haven’t fixed the single quotes and double quotes enclosing issue. I think replacing single quotes with double quotes and vice-versa, as I did mention in the first post will solve the issue (in fact I know so because I’ve already done it and it worked).

    jQuery('head').append('<scr' + 'ipt type="text/javascript" src="<?php echo plugins_url( "jquery.js" , __FILE__ );?>"></scr' + 'ipt>');

    To sum up, because valid HTML needs to enclose attribute values in double quotes (“), you need to enclose the strings belonging to Javascript which are parts of HTML code within single quotes. PHP only interprets code within the PHP tags, and it is interpreted first and replaced with the actual path, so it doesn’t matter which ones you use to enclose strings belonging to PHP code. Javascript has to use single quotes, because using double quotes would mean needing to escape every double quote within the HTML-part strings with a backslash. So, we have PHP and HTML usding double-quoted strings inside Javascript using single-quoted strings.

    Then the javascript is syntactically correct and won’t break execution.

    I appreciate your work and helping me, but you keep releasing revisions for every comma edit and I’m tired of re-updating the plugin manually everytime and testing it when it’s clearly not necessary. I suggested changing the enclosing quotes from the very beginning, and I’ve wasted the last hours only to return to that conclusion. I’m going to take a headache break to play some poker and come back later to test and report issues, if any.

    Please let me know when you update that part of the code by replacing the single quotes surrounding that partial HTML string in Javascript with double quotes or by escaping the double quotes surrounding the path to jQuery using backslashes. For now, revision 17 still has double quotes inside a double-quoted string, breaking the javascript script execution.

    I repeat, disabling the jQuery check doesn’t solve the problem – the syntactic error still prevents execution of the script. I’m debugging the live javascript code in the browser’s console. I’m the same age as you, but I was never taught programming in school. My IT teachers were never present, I’m learning it as a hobby, so I’m sorry if I appear as if I was telling you what to do, but it just seems such a trivial task. If I’m wrong about anything, just say so. I’m only trying to help.

    Plugin Author Dean Williams


    I learned the same as you, but a few years ago now. I now work for a company and run my own freelance.

    I’m VERY knowledgeable with javascript and for me there is NO problem with that code…

    Could you please send me a link to your site so I can check this out (leave the problem there so i can see it).

    I have no idea why you are having this problem. There should not be ANY quotes in there to cause the problem.

    Plugin Author Dean Williams


    What browser are you using??

    Plugin Author Dean Williams


    And sorry for the constant releases, I was at work and made a few mistakes as I wasnt able to test my code or concentrate as I would usually.

    My Bad!

    I will take a better look tonight while not at work, maybe your right and I’m missing the big picture.

    I’m using Google Chrome version 21.0.1180.83
    This may be Chrome’s doing indeed, because in the Javascript debugger and in the live code examiner, the string appears within double quotes, but I checked the PHP file and it is now in single quotes (I told you that is not valid HTML).
    Thank you for taking the time.

    Plugin Author Dean Williams


    omg your right!!

    I have a test version on my blog where I fixed this, and I was failing to see the mistake! And because my other test blogs include jquery okay without that check everything works fine.

    I will release a fix tonight.

    I do apologise for arguing against you (and being so dumb not to see this), major fail on my part :/

    Plugin Author Dean Williams


    I use Chrome too, but yeah very strange!

    I wil lget to the bottom of this when I get home 😉

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘[Plugin: Advanced AJAX Page Loader] AAPL_warnings not defined’ is closed to new replies.