I've tried to load Disqus with ajax in my page, i'll explain. I have one page inside it i have jqrusel, with differents images and each one have its comments.
So , when i clicked on one of this images, i have done this code:
$.get("/sets/comentarios",{set_id:set_id},function(data){
$("#componet_comentarios").html(data);
and this url load :
var disqus_identifier = 'votar-<?= $id; ?>';
var disqus_url = 'www.mitrendy.com/votar/<?= $id; ?>';
// Remove the old script if it's found
oldDsq = document.getElementById('MitrendyComentDisqus');
if(oldDsq) {
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).removeChild(oldDsq);
}
(function() {
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.id = "MitrendyComentDisqus-<?= $id; ?>";
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
but never refresh the comments. Later i saw in official page of disqus :
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = "newidentifier";
this.page.url = "http://example.com/#!newthread";
}
});
but it's the same, when i tried to load the comments with ajax, never refresh it.
Any idea ? i crazy with it.
Thanks to anybody!!
I had similar problem, I moved my site to ajax and the subpage previously included in php, which contains disqus js, now is loaded using ajax (container for disqus and its scripts) but when this is not loaded with whole page, the scripts are not evaluated. So I moved them to global .js file and wrap in function, like this:
var disqus_shortname = 'myname';
var disqus_identifier = 'myident';
function loadDisqus() {
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
}
and after ajax loads content, I call loadDisqus();
and the board loads.
In your example, you should also pass identifier as parameter and define it when calling, everything should work properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With