Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

JoomlaTune Support Forum    JComments component    Integration with third-party extensions    Topic: JComments in com_content with AJAX
Pages: [1]   Go Down
  Print  
Author Topic: JComments in com_content with AJAX  (Read 8576 times)
0 Members and 1 Guest are viewing this topic.
tecap
Newbie
*

Karma: 0
Offline Offline

Posts: 2


Email
« on: October 10, 2010, 13:57:11 »

Hi everybody,

I develop a component in which I call the com_content component in a div with XMLHttpRequest (AJAX).
Code:
window.onload = function(){
        var id = document.getElementById("id").value;
        if (id !=0) {    generalQuery('index2.php',document.getElementById('definition'),'GET','option=com_content&task=view&id='+id);}
        else { document.getElementById('definition').innerHTML='Pas encore de définition pour ce tag par votre groupe.';}
        }

The generalQuery function:
Code:
function generalQuery(serveur, reponse, methode, parametres){
var xhr = getXhr(); //Nouvelle instance Ajax

if (xhr && serveur){
// On défini la fonction observant la communication Ajax/serveur
    xhr.onreadystatechange = function(){
        // le code 4/200: détermine que Ajax a reçu une réponse du serveur
        if(xhr.readyState == 4 && xhr.status == 200){
            reponse.innerHTML = xhr.responseText;//renvoit la réponse du serveur dans le conteneur reponse
                 }
            }
        }    

    // Déclenchement de l'appel Ajax/serveur + envoi paramètres POST ou GET
    if (methode == "POST"){
        xhr.open("POST", serveur, true);
        xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        xhr.send(parametres);
        }
    else {
        xhr.open("GET", serveur+"?"+parametres, true);
        xhr.send(null);            
        }          
    }
}

I have integrated JComments and the display is OK.
The problem is that the "save" button (below the comment to post) does'nt work. When clicking on the button, the debugger indicates "jcomments is not defined".

Do you know where is the problem?
Thanks very much for any help!
« Last Edit: October 10, 2010, 13:59:05 by tecap » Logged
smart
Administrator
Hero Member
*****

Karma: 187
Offline Offline

Gender: Male
Posts: 1883



WWW
« Reply #1 on: October 11, 2010, 01:33:34 »

This is because article's page with JComments contains some blocks with  JavaScript. These scripts must be passed through eval function to inialize JComments' object.
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
tecap
Newbie
*

Karma: 0
Offline Offline

Posts: 2


Email
« Reply #2 on: October 11, 2010, 02:42:26 »

Thanks very much for your answer.
Today I understood that the problem came from the javascript code with ajax. I tried to use the eval() function but I don't understand how it works... (I'm a novice with javascript and ajax)
Could you give me an example?
And which scripts must be passed through this function to initialize JComments' object?
Thanks again for your help!
Elise
Logged
smart
Administrator
Hero Member
*****

Karma: 187
Offline Offline

Gender: Male
Posts: 1883



WWW
« Reply #3 on: October 11, 2010, 02:49:04 »

Sorry I'm too busy now to give any examples. The eval function allows run any piece of JS code. You need parse article's code for scripts and pass these code blocks through eval.
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
fsohrabi47
Newbie
*

Karma: 0
Offline Offline

Posts: 1


WWW Email
« Reply #4 on: November 18, 2017, 19:14:39 »

This is one of the best tutorial.
You can follow us for more details.







« Last Edit: December 11, 2017, 16:25:23 by fsohrabi47 » Logged

Eddiecolin05
Newbie
*

Karma: 0
Offline Offline

Gender: Male
Posts: 2



WWW Email
« Reply #5 on: November 22, 2017, 15:42:01 »

Thank you for your answer and we know you are too busy person but can you explain when you free.
Logged

Get best Essay Help UK
Tabaneshahr
Newbie
*

Karma: 0
Offline Offline

Posts: 1



WWW
« Reply #6 on: November 26, 2017, 12:01:48 »

Can you explain about parameters of RequestHeader() method? Huh
Logged
mozza
Sr. Member
****

Karma: 0
Offline Offline

Posts: 389


Email
« Reply #7 on: December 23, 2017, 16:54:29 »

Really informative post. I really enjoyed and bookmarked it. Thanks for sharing.
Agen Poker Online
Agen Domino99 Online
Agen BandarQ
Logged
jessy
Full Member
***

Karma: 0
Offline Offline

Posts: 71


« Reply #8 on: January 01, 2018, 17:32:28 »

Agen BandarQ
Agen Adu Q
Bandar Domino Online
Bandar Domino
Agen Domino
Logged
ular
Full Member
***

Karma: 0
Offline Offline

Posts: 103


Email
« Reply #9 on: January 06, 2018, 11:07:35 »

Agen BandarQ
AgenIDR
Bandar Sakong
Agen BandarQ
Logged
Pages: [1]   Go Up
  Print  
JoomlaTune Support Forum    JComments component    Integration with third-party extensions    Topic: JComments in com_content with AJAX
 
Jump to: