Forums de discussion
Load a web content using Ajax
major major, modifié il y a 10 années.
Load a web content using Ajax
New Member Publications: 13 Date d'inscription: 01/11/12 Publications récentes
I'm using Liferay 6.06.
When I click a button in a page I need to show a div which is populated dynamically with a web content.
I want to load this web content using ajax.
How this can be done?
When I click a button in a page I need to show a div which is populated dynamically with a web content.
I want to load this web content using ajax.
How this can be done?
Pankaj Kathiriya, modifié il y a 10 années.
RE: Load a web content using Ajax (Réponse)
Liferay Master Publications: 722 Date d'inscription: 05/08/10 Publications récentes
You can get content in form of String by below code if you have articleId with you.
Make use of serveResource method to use ajax.
Write below code in serveResouce method
You can get it this content in ajax call in success function as a data.
For example if you are using jquery for ajax then below code would be helpful
HTH,
Pankaj K | CIGNEX Datamatics
String content=JournalArticleLocalServiceUtil.getArticleContent(themeDisplay.getScopeGroupId(),articleId,null,themeDisplay.getLanguageId(),themeDisplay)
Make use of serveResource method to use ajax.
Write below code in serveResouce method
String content=JournalArticleLocalServiceUtil.getArticleContent(themeDisplay.getScopeGroupId(),articleId,null,themeDisplay.getLanguageId(),themeDisplay)
resourceResponse.getWriter().write(content);
You can get it this content in ajax call in success function as a data.
For example if you are using jquery for ajax then below code would be helpful
jQuery.ajax({
url:'<portlet:resourceurl>
<portlet:param name="articleId" value="3"></portlet:param>
</portlet:resourceurl>',
success:function(response){
jQuery("#articleContentBox").html(response);
}
});
HTH,
Pankaj K | CIGNEX Datamatics