WordPress.org

Ready to get started?Download WordPress

Forums

Top 10 - Popular posts plugin for WordPress
[resolved] top 10 v1.9.6: Correcting calls to counter-script (6 posts)

  1. speedpartner
    Member
    Posted 1 year ago #

    Hi,

    We've encountered that the AJAX-calls to the counter-scripts didn't work out as expected. When running the plugin using a Firefox-client in the webserver-logs we got something like:

    /wp-content/plugins/top-10/top-10-addcount.js.php?top_ten_id=13422&

    which misses GET-parameters activate_counter and top10_rnd.

    Looking into the HTML-source it seems that for some reason the ampersands (&) in the JavaScript got replaced by something like & (if I remember correctly). Turning the AJAX-calls in the source to & made it work for Firefox, but it didn't seem to work in Opera then. After call, what was needed would be simple and plain ampersands.

    To workaround this problem (wherever that escaping may have come from) we modified the JavaScript in wp-content/plugins/top-10/top-10.php in tptn_add_viewed_count() to a different calling-syntax for the jquery-AJAX-calls, passing in an array for the get-parameters:

    jQuery.ajax({url: "' .$tptn_url. '/top-10-addcount.js.php", data: {top_ten_id: ' .$id. ', activate_counter: ' . $activate_counter . ', top10_rnd: (new Date()).getTime() + "-" + Math.floor(Math.random()*100000)}});

    Did others encounter the same problem? How do you think about this solution? That seems to have fixed it for us now.

    http://wordpress.org/extend/plugins/top-10/

  2. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Does this fix it for you universally across all browsers. Most users have reported problems with the counts not getting recorded.

  3. speedpartner
    Member
    Posted 1 year ago #

    Seems to work for us with the browsers we tested so far, yes (Firefox, Opera, ...) and logs are back to normal.
    jQuery offers both alternatives - either giving a string with ampersands or giving the parameters separately as a JS-array.

  4. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks. Let me test this on my installs

  5. hadingr
    Member
    Posted 1 year ago #

    Hello speedpartner, your solution doesn't work for my site.
    Note that, I use AIOSEOP. I had cleaned all caches to make sure the new codes is running.. Please check my site. I'll keep this change for 6 hours ahead.

  6. speedpartner
    Member
    Posted 1 year ago #

    I think/hope I was still on time now to check it out.
    It didn't perform *any* XHR for me. Actually it even failed loading a JS-file (some minify-thing) with a 500 Internal Server Error. I guess that might be relatd?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic