Hi all,
Are there any plugins with source available that make AJAX / XmlHttpRequest calls? I'd like to try and make AJAX calls from a Velocity template and have an idea, but I'd like to see how other plugins do this as well. If you know of a Velocity template and a corresponding XWork action in the Confluence source, that would work as well.
Feel free to tag / suggest tags for this question if you feel it applies to the development of plugins for other applications.
Thanks,
Jim
Community moderators have prevented the ability to post new answers.
You can use jQuery's ajax method to make an asynchronous call to a Confluence XWork action.
If you want to return JSON from the Action, the easiest thing to do is make your Action implement the com.atlassian.confluence.core.Beanable interface. In the getBean() method you can return an object and it will get serialised to JSON automatically.
You can pass any parameters to the Action as query parameters in the ajax call. (eg. /confluence/my-url/myaction.action?parameter=true).
The script to call the action would look something like this:
var requestSettings = { async: true, url: AJS.params.contextPath + "/actions/my-action-path/myaction.action timeout: 30000, // 30 seconds. success: function(data) { AJS.log("request successful");
// do something with the data.
}, error: function(data) { AJS.log("request failed."); } }; $.ajax(requestSettings);
Thanks Joseph! I see how it all fits together -- thanks for your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
com.atlassian.confluence.core.Beanable interface is Deprecated Interfaces. What is the alternative solution?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.