4 Replies Latest reply on Apr 23, 2007 6:13 PM by Sol Kindle

    Trigger ajax load from javascript

    Sol Kindle Newbie

      Is there an easy way for me to trigger an ajax4Jsf load/call from a javascript function?

        • 1. Re: Trigger ajax load from javascript
          Sergey Smirnov Master

          it is very easy. just use a4j:jsFunction

          • 2. Re: Trigger ajax load from javascript
            Sol Kindle Newbie

            Thank you for your reply.

            The a4j:jsFunction triggers a javascript function after the ajax call has been invoked.

            What I am looking for is a way to invoke the ajax call via javascript and have the returned data update the components specified in an a4j: tag's reRender attribute list.

            I hope this makes sense.
            Is this possible?

            Thank you for your time :)

            • 3. Re: Trigger ajax load from javascript
              Sergey Smirnov Master

               

              "kindsol" wrote:
              The a4j:jsFunction triggers a javascript function after the ajax call has been invoked.


              No, it is invoked BEFORE and used for sending the ajax request as well

              "kindsol" wrote:

              What I am looking for is a way to invoke the ajax call via javascript and have the returned data update the components specified in an a4j: tag's reRender attribute list.


              This is what jsFunction is designed for.

              jsFunction has a name attribute. This is a name of the javascript function you can use to invoke the ajax request.
              jsFunction can have f:param and a4j:actionparam children that are used for for passing parameters of the javascript function to ajax request
              jsFunction has a data attribute that is used to return data from the server (in JSON format)
              jsFunction has an oncomplete attribute that you can use to invoke any javascript function and pass the data taken from data attribute

              Do you need more info?




              • 4. Re: Trigger ajax load from javascript
                Sol Kindle Newbie

                OK. I got it. This tag renders into a javascript function with the name given by the "name" attribute

                I got it working -- thank you for bearing with me :)