send Ajax Request to XWork

Max Madjarov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2013

Hi,

I have defined a javascript function:

function fnSendAssessment(skillTitle, selfAssessment) {
    var postdata = {'selfAssessment': selfAssessment, 'skillTitle' : skillTitle};
    var url = AJS.params.contextPath + "/clientspace/setassessment.action";
    AJS.$.ajax({
        type: "post",
        url: url,
        data: postdata,
        success: function() {
            alert("ok");
        },
        error: function(response) {
            alert("Uuups!");
        }
    }); //ajax call
}

and I will call a XWork Action which is declared in xml (atlassian-plugin.xml):

<action name="setassessment"  class="de.twt.confluence.plugins.actions.CaptureSkillsAction" method="setassessment">
                <result name="redirect" type="velocity">captureskills.action</result>
</action>

but i get always only error back... which is the right way to send ajax requests to XWork Actions? Is there some examples?

Thanks :-)

1 answer

1 accepted

1 vote
Answer accepted
Max Madjarov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2013

it works :-)

Nabil Sayegh
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 4, 2013

Would you mind enlighten the rest of us about what was wrong? ;-)

Jeffrey October 9, 2014

Thanks for the answer could someone please tell me how to define this javascript function? I have the following inside my .vm file and get a velocity parse error.

Jeffrey October 9, 2014

<h2>Twikkir Panel</h2> Enter Twikkir message (<span class="smalltext" id="charsleft">140</span>): <br /> <form name="twikkirpost"> <div> <label for="name">Name</label> <input type="text" id="name" name="name"> </div> <div> <label for="time">Time</label> <input type="text" id="time" name="time"> </div> <div> <input id="mybutton" type="button" value="Post It" onclick="postit();"/><br /> </div> </form> <script type="text/javascript"> document.getElementById('mybutton').onclick = function() { var url = AJS.params.contextPath + "/plugins/twikkir/postit.action"; AJS.$.ajax({ type: "post", url: url, success: function() { alert("ok"); }, error: function(response) { alert("Uuups!"); } }); //ajax call } </script>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events