Support » Plugin: Yasr - Yet Another Stars Rating » YASR not working in AJAX returned content

  • I have got YASR working on my site, but whenever I try to use the shortcode during AJAX returned content it silently fails and nothing is returned. (a) Is this a known issue that YASR isn’t compatible with AJAX calls? (b) Is there a workaround (e.g. a function that allows a YASR star rating to be output that won’t fail during the AJAX call. Something like do_shortcode( ‘[yasr_manual_rating rating=”4.6″ size=”small”]’)? At least then I could manually extract the YASR rating for a post and then generate the star rating.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author dudo

    (@dudo)

    Hello konigrot, I’m working and testing Yasr to make it work on ajax returned content, should be available from next yasr 1.4.1 🙂

    Plugin Author dudo

    (@dudo)

    Just released version 1.4.1

    Remember to delete all your caches and it will work 🙂

    Thanks for the quick response! I have updated the plugin on my site (no caching being used) and still not getting any output in ajax content running the following: do_shortcode( ‘[yasr_overall_rating postid=”44″ size=”small”]’) where 44 is the correct ID for the rated post, and the same function works ok in non-ajax content output.

    As mentioned before, it might be useful if there was a function to manually output a rating because: (a) it would offer a workaround option for these cases and (b) I would like to use the yasr ratings visuals for a custom category-like taxonomy in addition to standard post ratings. 🙂

    Plugin Author dudo

    (@dudo)

    Do you have a link to the site?

    If it is ajax content, it must work now.

    I setup the test function:

    add_action(‘wp_ajax_nopriv_bh_test’, ‘bh_test_func’);
    add_action(‘wp_ajax_bh_test’, ‘bh_test_func’);
    function bh_test_func() {
    if($_POST){
    echo( ‘<p>AJAX RETURN</p>’ );
    echo( do_shortcode( ‘[yasr_overall_rating postid=”44″ size=”small”]’) );
    echo( do_shortcode( ‘[gallery columns="2" ids="57,58,59,60" size="screenshot"]‘ ) );
    exit();
    }
    echo( ‘Error: Please refresh the page’ );
    die();
    }

    and when the function is run from the front end the gallery shortcode output works fine, but nothing from the yasr shortcode. However, in the page load I manually call:

    echo( do_shortcode( ‘[yasr_overall_rating postid=”44″ size=”small”]’) );

    and the output works ok. I have version 1.41 of YASR and WP version 4.5.3. The site is a testbed – how can I privately share the access with you?

    • This reply was modified 1 year, 2 months ago by  konigrot.
    • This reply was modified 1 year, 2 months ago by  konigrot.
    Plugin Author dudo

    (@dudo)

    Write a comment to the yasr official site, refer to this thread, and I’ll contact you on email 🙂

    Comment left on https://yetanotherstarsrating.com/f-a-q/comment-page-4/#comment-14996

    • This reply was modified 1 year, 2 months ago by  konigrot.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘YASR not working in AJAX returned content’ is closed to new replies.