WordPress.org

Ready to get started?Download WordPress

Forums

Advanced AJAX Page Loader
[resolved] AAPL_warnings not defined (20 posts)

  1. bitoolean
    Member
    Posted 1 year ago #

    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.

    http://wordpress.org/extend/plugins/advanced-ajax-page-loader/

  2. bitoolean
    Member
    Posted 1 year ago #

    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.

  3. Dean Williams
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  4. bitoolean
    Member
    Posted 1 year ago #

    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.

  5. bitoolean
    Member
    Posted 1 year ago #

    Is this only happening to me? Check this at indignat.socioblog.ro (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="http://indignat.socioblog.ro/wp-content/plugins/advanced-ajax-page-loader/jquery.js?84cd58"></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)

  6. Dean Williams
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  7. Dean Williams
    Member
    Plugin Author

    Posted 1 year ago #

    BTW - if you want to disable the jQuery check there is an option in the admin panel called "Enable jQuery check."

  8. bitoolean
    Member
    Posted 1 year ago #

    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.

  9. bitoolean
    Member
    Posted 1 year ago #

    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.

  10. bitoolean
    Member
    Posted 1 year ago #

    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.

  11. Dean Williams
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  12. Dean Williams
    Member
    Plugin Author

    Posted 1 year ago #

    What browser are you using??

  13. Dean Williams
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  14. bitoolean
    Member
    Posted 1 year ago #

    Hi
    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.

  15. Dean Williams
    Member
    Plugin Author

    Posted 1 year ago #

    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 :/

  16. Dean Williams
    Member
    Plugin Author

    Posted 1 year ago #

    I use Chrome too, but yeah very strange!

    I wil lget to the bottom of this when I get home ;)

  17. bitoolean
    Member
    Posted 1 year ago #

    Just use double qoutes instead of single and single instead of double. For HTML attribute values, it's better not to enclose them in any quotes at all than using single quotes.
    OK, I will return with more results tomorrow or whenever you update it then. I'd use Firefox otherwise, but my machine is a slow one and Chrome is faster and better for debugging and checking live HTML/CSS/Javascript anyway.
    Oh and my website address is indignat.socioblog.ro, which is listed in my profile too (you've asked in my other posts too, so just check it when you're theRE, so you don't have to wait for my answer).

  18. bitoolean
    Member
    Posted 1 year ago #

    I don't know how this has been working for you and other people. Because of the double-quotes within a double-quoted javascript string, the script has been broken for me ever since I've been using the plugin.

    I repeat, that syntactic error made the whole javascript part not be interpreted and leading to errors like "AAPL_warnings not defined", which broke the functionality of the plugin (content didn't load by AJAX). That's why I've been so surprised.

  19. Dean Williams
    Member
    Plugin Author

    Posted 1 year ago #

    It's worked because I have jquery loaded properly in my wordpress so this check is never run by javascript so no error occurs.

    I cant believe javascript replaces all ' with " on html attributes, something to watch for in future!

    Anyway 1.6 is up - I have taken the time to clean up the admin page and also add a new option, mainly to apologise but also because now I'm going to add many more customization options :)

  20. bitoolean
    Member
    Posted 1 year ago #

    I don't recall the HTML reference documentation saying anything about single quotes. They always advise enclosing all attribute values between double quotes, even numbers (because many people didn't, and not every version of every browser behaved the same in this case), and XHTML strict even requires them in order to validate.

    This is the piece of code I'm using in a hook to wp_enqueue_scripts():

    if( !is_admin() ){
      wp_deregister_script("jquery");
      wp_enqueue_script("jquery", "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");

    I don't understand how that is an improper way of loading jQuery, except for the fact that I don't specify a version string (the fourth parameter in the function definition), but I wouldn't know that before jQuery is even loaded anyway, because I only specify the major version in the URL as a wildcard to always get the latest version of the script.

    You're dedicating your time and you're doing a great work, and that's indeed all the apology anyone needs. Plus, AAPL deserves the full 5 stars, because, like you said, it's not its fault, it's the nature of AJAX and it's current limitations.

    No more exceptions appear in the Javascript console :D
    But, the "..." links still don't work with AJAX. I need other links to posts than the excerpt titles to load with AJAX as well - the links at the end of excerpts should load the full post with AJAX too, and so should the list of "related links" (a scroller of links to other posts from the same category) which I need to update whenever the post changes (even by AJAX, but that's a suggestion for which I'm going to start a new thread). In other words, how do I "ajaxify" links? Answer to this question in its own thread here, please: http://wordpress.org/support/topic/plugin-advanced-ajax-page-loader-ajaxify-the-more-link-at-the-end-of-excerpts-too?replies=3

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.