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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

309 views 4 9
Read article

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