Skip to content

Instantly share code, notes, and snippets.

@arvindm1
Created November 14, 2011 16:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arvindm1/1364318 to your computer and use it in GitHub Desktop.
Save arvindm1/1364318 to your computer and use it in GitHub Desktop.
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