We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5160
    • 118 Posts
    Expected behaviour
    The pdoPage call below should load 2 more resources when the Load More button is selected

    Actual behaviour
    Testing in Chrome and Firefox side by side intermittently results in the ajax request to /assets/components/pdotools/connector.php returning a 200 OK response with no payload (0kb). It should return JSON string.

    Related information



    • saving the Resource with the pdoPage call then refreshing the page in the affected browser makes the Load more button work as expected
    • changing the pdoPage call slightly eg. &limit=`1` then refreshing the browser sometimes results in Load More working, sometimes it returns the same empty 200 OK response

    I know the pdoPage call is uncached, this is deliberate because the Statcache plugin is running. As I understand it caches the main body of the page, not the Ajax call to pdoTools connector.php.

    The pdoTools connector.php runs the pdoPage snippet using modX::runSnippet which is always uncached so it should work as I expect?

    If I change the call pdoPage call to uncached [[!pdopage]] the Load More ajax call works as expected every time, I can't make it fail as described above.

    Can anyone advise if pdoPage can be used in cached calls as I expect it can?

    Otherwise what did I miss?

    Thanks,

    Chris
      • 3749
      • 24,544 Posts
      If you turn on dev. tools in Chrome or FF, do you see any JS errors on the console tab when it fails?

      When you try to call pdoPage cached, are any placeholder tags in your TPLs called uncached (e.g., +assetsUrl)? That will delay their processing and their values won't be there when needed.

      If not, my wild guess would be that the pdoPage ajax code has a 'success:' function, but doesn't check for an empty payload.
        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
        • 5160
        • 118 Posts
        If you turn on dev. tools in Chrome or FF, do you see any JS errors on the console tab when it fails?
        No JS errors logged in the console when the issue presented.

        When you try to call pdoPage cached, are any placeholder tags in your TPLs called uncached (e.g., +assetsUrl)? That will delay their processing and their values won't be there when needed.
        There are several placeholders and snippet calls in the TPL and all calls are cached.

        I should mention the site runs pdoParser not the default modParser. So all tags should be processed in a single pass, modParser would only be called if pdoParser could not process all the tags.

        If not, my wild guess would be that the pdoPage ajax code has a 'success:' function, but doesn't check for an empty payload.
        That would make sense if there is no check for an empty payload. pdoPage applies a loading state css class to the target container <div> when Load More is triggered. When I experience the issue this class is not cleared when an empty payload is received.

        The response from the ajax call to connector.php was intermittent, sometimes containing the next row, sometimes empty.

        My javascript skills are extremely limited, the script in question is on github at https://github.com/bezumkin/pdoTools/blob/master/assets/components/pdotools/js/pdopage.js

        I'm unsure where to go from here.
          • 3749
          • 24,544 Posts
          In the Ajax call, there is this:

          if (response && response['total']) {
             /* ... display page */
          }
          


          There is no else clause, so if the processor doesn't return JSON, nothing will happen. In the processor (which doubles as a snippet), it looks like there are places where it returns false or an empty string. It doesn't appear to ever return an error message.
            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