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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

195 views 18 7
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