Wednesday, 8 November 2017

Passing form in ajax call

We can pass whole form in ajax call by serializing the form

In your script:

var str = $('#<portlet:namespace/>formID').serialize();
$.ajax({
 type: "post",
 data: str,
 dataType: 'text',
 url: "<%=submitJobURL%>",
 async: false,
 success: function(data) {
  alert("success");
 }
});

And your form view in jsp:
<aui:form method="post" name="formID">
<aui:input name="formID" type="text" />
</aui:form>

Here formIDis your form id.

And we can get values in controller by normal way

String formID= ParamUtil.getString(request,"formID");

TEST

I am Java Developer. I have 6 year Experiance in this field and like to post in blogging. So keep sharing and like my post

0 comments:

Post a Comment

 

Copyright @ 2017 Liferay Article.