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>


 

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.
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!