Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Sudarshan Kumar
Ajax call in Liferay
August 12, 2011 2:44 AM
Answer

Sudarshan Kumar

Rank: New Member

Posts: 2

Join Date: July 4, 2010

Recent Posts

Can anybody suggest me, how to do Ajax call in liferay
Pranay R Patadiya
RE: Ajax call in Liferay
August 12, 2011 3:19 AM
Answer

Pranay R Patadiya

Rank: Regular Member

Posts: 181

Join Date: February 22, 2010

Recent Posts

Hi Sudarshan,

Please refer link : Ajax In Liferay

You can also use DWR as a alternative of ajax.

Let me know if you want anything else.

Thanks,
Pranay
Tanweer Ahmed Ansari
RE: Ajax call in Liferay
August 12, 2011 11:25 AM
Answer

Tanweer Ahmed Ansari

Rank: Regular Member

Posts: 217

Join Date: March 11, 2010

Recent Posts

Sudarshan Kumar:
Can anybody suggest me, how to do Ajax call in liferay


Hi Sudarshan,

On any event of your Html element, you can call a javascript method, where you can get and sent the form values to a particular URL.
Find the example below.Here I am using jQuery Ajax to send some value to a particular URL and getting the response in the success block.

 1
 2function getRegions(){
 3        var country = jQuery('#<portlet:namespace />location').val();
 4        var select = null;
 5        var regionArray = [];
 6        var regionSubArray = [];
 7        jQuery.ajax({
 8               type: "POST",
 9               url: "<%= ajaxSelectURL.toString() %>",
10               data: "country="+country,
11               error: function()
12                 {
13                   alert("AJAXError");
14                 },
15               success: function(data){
16                     regionArray = data.split(",");
17                     select = jQuery('#<portlet:namespace />region');
18                     document.dealerForm.<portlet:namespace />region.length = 0;
19                     select.append("<option value='Select a region'>Select a region</option>");
20                     jQuery.each(regionArray, function(index, regionData) {
21                         regionSubArray = regionArray[index].split("+");
22                         if(regionSubArray.length > 1)
23                             select.append("<option value='"+  regionSubArray[0] +"'>"+ regionSubArray[1] +"</option>");
24                     });
25                }
26        });
27    }


Hope this helps.

Regards,
Tanweer
mPowerian-BoschLer
Manikandan S
RE: Ajax call in Liferay
September 5, 2011 4:27 AM
Answer

Manikandan S

Rank: Expert

Posts: 492

Join Date: September 15, 2010

Recent Posts

I think Ajax tool kit no longer to be used for Liferay's new version.

Yes better to choose DWR DWR Link Or jQuery Link
Ravi Kumar Gupta
RE: Ajax call in Liferay
August 19, 2011 5:06 AM
Answer

Ravi Kumar Gupta

Rank: Liferay Legend

Posts: 1137

Join Date: June 23, 2009

Recent Posts

If you need any sample portlet on Ajax-JQuery here is the http://sourceforge.net/projects/ajaxjqueryportl/

This portlet uses both actionURL and resourceURL with Ajax.
Sujay Kumar Paul
RE: Ajax call in Liferay
January 14, 2014 5:53 PM
Answer

Sujay Kumar Paul

Rank: Regular Member

Posts: 165

Join Date: October 28, 2011

Recent Posts

Hi,

Can any one please tell me how to get the value of data from struts 2 action class.

Thanks in advance.
Meera Prince
RE: Ajax call in Liferay
January 14, 2014 10:13 PM
Answer

Meera Prince

Rank: Liferay Master

Posts: 808

Join Date: February 8, 2011

Recent Posts

Hi
I have done struts 2 plugin portlet with jquery

The concept like send ajax call to struts action using URL and there u have to produce json or xml data based on your requirement.. and one more thing in struts config we need to configure json related configuration

Please go through following link and use as reference

http://www.liferaysavvy.com/2013/02/struts2liferay-service-builder-jqgrid.html

Regards,
Meera Prince

http://www.liferaysavvy.com