Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
major major
Load a web content using Ajax
9 septembre 2013 02:49
Réponse

major major

Rang: New Member

Publications: 13

Date d'inscription: 1 novembre 2012

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?
Pankaj Kathiriya
RE: Load a web content using Ajax
9 septembre 2013 04:01
Réponse

Pankaj Kathiriya

Rang: Liferay Master

Publications: 697

Date d'inscription: 4 août 2010

Publications Récentes

You can get content in form of String by below code if you have articleId with you.

1String content=JournalArticleLocalServiceUtil.getArticleContent(themeDisplay.getScopeGroupId(),articleId,null,themeDisplay.getLanguageId(),themeDisplay)


Make use of serveResource method to use ajax.
Write below code in serveResouce method
1String content=JournalArticleLocalServiceUtil.getArticleContent(themeDisplay.getScopeGroupId(),articleId,null,themeDisplay.getLanguageId(),themeDisplay)
2resourceResponse.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
 1
 2    jQuery.ajax({
 3            url:'<portlet:resourceURL>
 4    <portlet:param name="articleId" value="3"></portlet:param>
 5</portlet:resourceURL>',
 6            success:function(response){
 7                jQuery("#articleContentBox").html(response);
 8                 }
 9});


HTH,
Pankaj K | CIGNEX Datamatics