Reputation: 289
I've this code
jQuery('#select_set').on("change", function() {
var data_id = {
action: 'yasr_send_id_nameset',
set_id: jQuery(this).val()
}
//Send value to the Server
jQuery.post(ajaxurl, data_id, function(response) {
jQuery('#yasr_rateit_multi_rating').html(response);
});
});
The response that i got from ajax is something like this
Qualità birra <div class="rateit" id="yasr_rateit_multi_0" data-rateit-value="" data-rateit-step="0.5" data-rateit-resetable="true" data-rateit-readonly="false">
</div> <br />
I can output just the simple text but i can't output the div: that div call a jquery plugin called "rateit". I think that i should reload the plugin after ajax response but I've not idea how to do this. I'm a total noob in js
Upvotes: 1
Views: 2208
Reputation: 61055
jQuery's post()
method takes the success function as a parameter, as you've done. Just include your plugin init statement there:
jQuery.post(ajaxurl, data_id, function(response) {
jQuery('#yasr_rateit_multi_rating').html(response);
jQuery('#myElement').rateIt();
});
https://api.jquery.com/jQuery.post
Upvotes: 1