Created
November 14, 2011 16:14
-
-
Save arvindm1/1364318 to your computer and use it in GitHub Desktop.
Ajax Alloy UI Call - JSP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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