jQuery ajax with liferay

On click on confirm ajax submit this form, and wherever your redirect in your class the ajax will redirect just the portlet.

<portlet:actionURL var="ajaxURL" name="atsglobaltechsoft" windowState="< %= LiferayWindowState.EXCLUSIVE.toString()%>" />

<script type="text/javascript" >
    function submitForm(){
        jQuery.ajax({
          type: 'POST',
          url: '<%= ajaxURL % >',
          success: function(data){
              jQuery('#p_p_id<portlet:namespace/ > .portlet-content').html(data);
          }
        });
    }
</script >


<form action="" name="fm" id="fm" method="post">
    <a href="#" onclick="submitForm();">confirm < /a>
</form>


 

More Blog Entries

thumbnail
thumbnail
Blogs
Very useful post Tauseef. Thanks for sharing.

Ahamed Hasan
Author, Liferay Cookbook
Hey Tauseef, can you let us know what this code is doing? It will be helpful for beginners to better understand the usefulness of this.
On click on confirm ajax submit this form, and wherever your redirect in your class the ajax will redirect just the portlet, not your whole page so nothing changes on the backend.
Ok, you should probably put this explanation in the actual blog post next time emoticon Not everyone reads comments..
Hello,

What if I want to call a Java function to store some form data in my database instead of doing it by javascript?

Thank you!