We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31782
    • 103 Posts
    I created a flash application, which can call JS function with the required parameters. I need that this JS code posted a comment with passed parameters on the same page where my app is located.

    For example Jot. How do I send Jot comment from JS function?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Use AJAX. I haven't used Jot as an AJAX processor although eForm works quite well, but since all Jot comments are in the database a custom PHP application could be used a the AJAX procesor to fetch what is desired from the database. Personally, I think that Flash -> Javascript -> PHP is a little convoluted; usually you can use Javascript alone to do just about anything on the client side that you might be using the Flash for; there is probably at least one JQuery plugin to do whatever your Flash is doing.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 31782
        • 103 Posts
        Thank you, sottwell.
        I prefer to work with Flash than with JQuery and Flash has great potential, but not the question. Apparently I did not say specifically what is required.

        I have a MODx site. On one page I have placed my flash application and under flash placed the user`s comments and I want to allow users to publish their achievements in the game in these comments in an automatic mode.
        For example, in HTML it works fine (see code below). I call PostComment function and the results appear in DIV blocks.
        How publish these results as jot comments?

        <script language="javascript">
        function PostComment(q, a, y, n) 
        { 
         var txt1=document.getElementById("question")
          txt1.innerText= q;
        var txt2=document.getElementById("answer")
          txt2.innerText= a;
          var txt3=document.getElementById("yesValue")
          txt3.innerText= y;
          var txt4=document.getElementById("noValue")
          txt4.innerText= n;
        } 
        </script>
        
        <div id="question"></div>
                <div id="answer"></div>
                <div id="yesValue"></div>
                <div id="noValue"></div>
          • 36404
          • 307 Posts
          hi,

          Susan's answer is the answer, use Ajax... the "only" way to have front and serverside communicating with js

          actually you'll simply have to call, with ajax, a page that contains a function, the jot native one or yours, that feeds the jot table.
          Don't forget to pass your user internalKey and a ressource id as params, it will help you sort and display the comments afterwards

          something, i haven't understood, is your form in your flash app too ? if yes, flash doesn't need js to send things the async way to ths server, all you need is to call a php page sending the infos the same way any flash form would do it

          have swing
            réfléchir avant d'agir
            • 31782
            • 103 Posts
            Hi
            I do not have forms. I have a flash game. Users play and get points. If the user wants to save his achievements in the game, he can publish it. They are published under a flash application in the form of comments feed.
            In my opinion I need to simplify the question:
            1. I have values ​​in the DIV:
            <div id="question">bla</div>
                    <div id="answer">No</div>
                    <div id="yesValue">567</div>
                    <div id="noValue">3845</div>

            2. How do I post a comment that these values ​​were in the comment? Probably something to params of snippet like this:
            [!Jot? &action=`comments` &title=`valueOfQuestion` &postBody=`valueOfAnswer + yesValue + noValue` !]
              • 36404
              • 307 Posts
              hi,

              well, honestly, now that i understand a bit more what you're trying to do, i would say "why use jot?"

              actually, the easiest way to do this would be to set a table of your own e.g. yourprefix_score with at least those two fields: id_user (or internalKey if you want to keep modx internal logic) and score, why not a date/timestamp to get a user progression and feed this table with a snippet of your own two (the smartest way being of course using ajax to do this

              jot has a complex structure you don't need to achieve what you're looking for

              have swing
                réfléchir avant d'agir