Skip to content

Instantly share code, notes, and snippets.

@arvindm1
Created November 14, 2011 16:14
Show Gist options
  • Select an option

  • Save arvindm1/1364318 to your computer and use it in GitHub Desktop.

Select an option

Save arvindm1/1364318 to your computer and use it in GitHub Desktop.

Revisions

  1. arvindm1 created this gist Nov 14, 2011.
    61 changes: 61 additions & 0 deletions Ajax-Alloy-UI-Call.jsp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,61 @@
    <!-- 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>