WordPress.org

Ready to get started?Download WordPress

Forums

WP-PostRatings
[resolved] Ratings stopped working still Loading (13 posts)

  1. kamgfx
    Member
    Posted 10 months ago #

    Not sure when or why this plugin stopped working, but I recently updated WordPress and many of the other plugins. I'm really not sure if this is what caused the problem, or if it occurred for another reason prior to this update.

    All the ratings are showing up, but when you place the cursor over the stars it won't let you select a rating.

    Any idea what's going on here???

    http://wordpress.org/plugins/wp-postratings/

  2. kamgfx
    Member
    Posted 10 months ago #

    my web site

    web

  3. Lester Chan
    Member
    Plugin Author

    Posted 10 months ago #

  4. RonStrilaeff
    Member
    Posted 10 months ago #

    I'm following this thread with a similar problem ...

    When I click on a star, the stars disappear and the loading gif stays forever. Refeshing the page shows that the ratings were increased by one vote so it appears to be working behind the scenes.

    Here is my test/dev site and the post I'm trying to rate.

    I will tidy up the css after I get this to work.

    Please help of you can Lester :-)

  5. Lester Chan
    Member
    Plugin Author

    Posted 10 months ago #

    @Ron Strilaeff: did u read what I replied? Your site doesn't have wp_head or wp_footer

  6. RonStrilaeff
    Member
    Posted 10 months ago #

    Yes I did check for wp_head() and wp_footer() and they are in the canvas wootheme header.php and footer.php files

    I have child theme but have not overridden those two files.

    That specific test page I referred to uses a page template file named single-recipe.php and that file has get_header() and get_footer() which according to the wp codex will execute the header.php and footer.php

    How did you determine that I am not executing the wp_head and wp_footer functions?

    I have just now put an echo in immediately after those calls in the canvas theme files. For a few minutes I had deactivated all plugins and went back to the default canvas theme, and the loading gif went away as hoped. There was another minor issue with borders on the star images but that can be solved later. Maybe you looked while it was in transition and a page was broken.

    For now I will not touch my config so if you wanted to investigate it is much appreciated.

    It may be related but I started getting this warning a couple of months ago ( I use jquery for other things on that page, like the favorite icon). I don't know how to fix that.

    JQMIGRATE: Logging is active
    jquery...r=1.2.1 (line 21)
    JQMIGRATE: jQuery.browser is deprecated
    jquery...r=1.2.1 (line 41)
    migrateWarn(msg="jQuery.browser is deprecated")
  7. Lester Chan
    Member
    Plugin Author

    Posted 10 months ago #

    Nope it has nothing to do with the warning you pasted. Your site doesn't load the Javascript/CSS files of WP-PostRatings which means your theme doesn't contain the <?php wp_head(); ?> in the header.php & <?php wp_footer(); ?> in the footer.php

    wp_head() and wp_footer() is different from get_footer() and get_header();

    get_footer/get_header executes the footer.php and header.php file, but if you do not have the wp_head() inside header.php and wp_footer() inside footer.php, it does not make a difference.

  8. kamgfx
    Member
    Posted 10 months ago #

    yes i will add wp_head() and wp_footer() its solved my problem

    thankx :)

  9. RonStrilaeff
    Member
    Posted 10 months ago #

    Hi Lester,

    I'm sorry that I confused the issue with that jqmigrate warning ... forget that.

    The point I was trying to make is that my pages DO make the call to wp_head() and wp_footer(). They have get_header() which includes header.php and that file executes wp_head(). Similarly for wp_footer(). I removed the echo now, but outputting some test text to the screen immediately before and after the call to wp_head() and wp_footer(), shows that they ARE executing on my test page.

    Also a view source for the page which has the ratings on it shows the loading of this:

    <link rel='stylesheet' id='wp-postratings-css'  href='http://testyng.com/wp-content/plugins/wp-postratings/postratings-css.css?ver=1.63' type='text/css' media='all' />

    and this:

    <script type='text/javascript'>
    /* <![CDATA[ */
    var ratingsL10n = {"plugin_url":"http:\/\/testyng.com\/wp-content\/plugins\/wp-postratings","ajax_url":"http:\/\/testyng.com\/wp-admin\/admin-ajax.php","text_wait":"Please rate only 1 post at a time.","image":"stars","image_ext":"gif","max":"5","show_loading":"1","show_fading":"1","custom":"0"};
    var ratings_mouseover_image=new Image();ratings_mouseover_image.src=ratingsL10n.plugin_url+"/images/"+ratingsL10n.image+"/rating_over."+ratingsL10n.image_ext;;
    /* ]]> */
    </script>
    <script type='text/javascript' src='http://testyng.com/wp-content/plugins/wp-postratings/postratings-js.js?ver=1.63'></script>

    Besides the dev version, the above is the only frontend js file in the plugin, so what other "Javascript/CSS files of WP-PostRatings" am I not loading?

    The ratings are saved by post and everything works fine except the loading gif stays there. Refreshing the page shows the number of ratings incremented by one.

    Is there a way to load the un-minimized version of the plugin js and insert some console.log statement to see where the conflict is and what's making it hang up at that point? I'm sure it's not your plugins' fault but something in my environment that I can eliminate.

    Thanks if you still want to help.

  10. RonStrilaeff
    Member
    Posted 10 months ago #

    Lester.. an update maybe good news.

    I saw that your function rate_post_success never executes in my env

    So I created an error: function for your ajax get call.

    The error I got was an invalid json char. hmmmm? so I noticed that the success function loads the respose data as html!

    I have other ajax functionality on most of my pages and I used the .ajaxSetup to set dataType: 'json'.

    So I added dataType: 'html' to your ajax get and it worked... the loading animation went away and the success function executed.

    So my solution is to eliminate my (not recommended) "global" json datatype from my ajax code and let your run normally. I'll let you know how that works.

    And maybe a suggestion to make your code more idiot proof (from guys like me) is to add the argument dataType: 'html' to your ajax calls

    Thanks, Ron

  11. Lester Chan
    Member
    Plugin Author

    Posted 10 months ago #

    Thank you Ron! I did that https://github.com/lesterchan/wp-postratings/commit/ff3e999387b727056830e0a6c125e90712a5626d =)

    Any reason why you don't let jQuery auto detect the dataType?

  12. RonStrilaeff
    Member
    Posted 10 months ago #

    No reason other than when I wrote that code I wasn't quite sure how to use the json format and wanted to make sure that all my ajax responses were using json to eliminate anything unexpected. So I put in a $.ajaxSetup({...} call along with my serverside url and a couple other options. I was a little over-zealous to "just make it work".

    In hindsight, the description and notes here says it is strongly not recommended http://api.jquery.com/jQuery.ajaxSetup/ so I un-did all that and specified json right before each of my ajax posts or gets if it was truly required.

    Thanks for your patience. Maybe this will help some other reader from the future.

  13. Lester Chan
    Member
    Plugin Author

    Posted 10 months ago #

    Thanks Ron =)

Reply

You must log in to post.

About this Plugin

About this Topic