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

    Trigger ajax load from javascript

    kindsol

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

        • 1. Re: Trigger ajax load from javascript

          it is very easy. just use a4j:jsFunction

          • 2. Re: Trigger ajax load from javascript
            kindsol

            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

               

              "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
                kindsol

                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 :)