As we all know many web applications are using ajax.
And really its magic of AJAX !!!
Here is the code how can we make ajax call in liferay :
Now Create getData.jsp file with below code sample code :
you can use your own logic to fetch the data.
And Now you will see How Ajax is easy with jquery and LifeRay !!!!!!!!
And really its magic of AJAX !!!
Here is the code how can we make ajax call in liferay :
jQuery.ajax({
url:'/html/portlet/journal/getData.jsp',
data: {
directoryIdParam: directoryId
},
dataType: 'json',
type: 'POST',
success: function(dataJson) {
alert(dataJson);
});
Now Create getData.jsp file with below code sample code :
you can use your own logic to fetch the data.
<%@page import="com.ext.portlet.productdirectory.service.http.ProductCategoryJSONSerializer"%>
<%@page import="com.ext.portlet.productdirectory.service.http.ProductDirectoryJSONSerializer"%>
<%@page import="com.ext.portlet.productdirectory.service.ProductCategoryLocalServiceUtil"%>
<%@page import="com.ext.portlet.productdirectory.model.ProductCategory"%>
<%@page import="java.util.List"%>
<%@page import="java.io.PrintWriter"%>
<% long directoryId=new Long(request.getParameter("directoryIdParam")).longValue(); PrintWriter writer=response.getWriter(); ListproductCategoryList =ProductCategoryLocalServiceUtil.getCategoryListByDirectoryId(directoryId);
writer.write(ProductCategoryJSONSerializer.toJSONArray(productCategoryList).toString());
writer.flush();
%>
And Now you will see How Ajax is easy with jquery and LifeRay !!!!!!!!