Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ajax Alloy UI Call - JSP
<!-- Create a serveResource URL -->
<portlet:resourceURL var="ajaxCallResourceURL" />
<aui:script>
Liferay.provide(
window,
'<portlet:namespace />saveEntry',
function() {
var A = AUI();
var url = '<%= ajaxCallResourceURL.toString() %>';
A.io.request(
url,
{
//data to be sent to server
data: {
<portlet:namespace />param1: 'hello1',
<portlet:namespace />param2: 'hello2',
},
dataType: 'json',
on: {
failure: function() {
},
success: function(event, id, obj) {
var instance = this;
//JSON Data coming back from Server
var message = instance.get('responseData');
if (message) {
alert(message.retVal1);
alert(message.retVal2)
}
else {
alert('no data back from server');
}
}
}
}
); //END of io Request
},
['aui-io']
); //End of Provide
</aui:script>
<aui:form action="<%= ajaxCallResourceURL.toString() %>" method="post" name="fm" >
<aui:button name="saveButton" onClick='<%= renderResponse.getNamespace() + "saveEntry();" %>' value="Click Me" />
</aui:form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment