send Ajax Request to XWork

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
Accepted answer

it works :-)

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

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.

<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
Community showcase
Posted yesterday in Agile

What is Scrum? A good, bad, and ugly answer.

In a world of dark-scrum, faux-scrum, and scrum-butt, the question still remains: What is scrum and how do you do it “right?” That’s the question we set out to answer. I'm Max, I've been teaching c...

75 views 0 4
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you