Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
deepthi narendula
Related to jquery+ajax
November 4, 2012 10:12 PM
Answer

deepthi narendula

Rank: Junior Member

Posts: 39

Join Date: April 26, 2012

Recent Posts

Hi Friends:

This is my Jsp,i need to delete the record in database for that i am using the following code but my problem is my action deletesearch is not performing..


<script type="text/javascript">
function deleteSearch(ths){
var searchId=$(ths).attr('title');
alert(searchId);
var url = "<%=fetchValues%>";
alert(url + "&searchId=" +searchId+ "&action=deleteSearch");
jQuery.ajax(url + "&searchId=" +searchId+ "&action=deleteSearch", function(data) {
});

}
</script>
This is my serve resource method :-
public void serveResource(ResourceRequest resourceRequest,
ResourceResponse resourceResponse) throws IOException,
PortletException {

System.out.println("in serve resource method");
String action = ParamUtil.getString(resourceRequest, "action");
if(action.equalsIgnoreCase("deleteSearch")){
int searchId=ParamUtil.getInteger(resourceRequest, "searchId");
try {
User_SearchLocalServiceUtil.deleteUser_Search(searchId);
} catch (PortalException e) {
e.printStackTrace();
} catch (SystemException e) {
e.printStackTrace();
}

}

Plz help me out....

Thanks & Regards
N.Deepthi
Pavel Savinov
RE: Related to jquery+ajax
November 5, 2012 12:18 AM
Answer

Pavel Savinov

Rank: Junior Member

Posts: 97

Join Date: September 24, 2012

Recent Posts

Hi.

Try to replace $ with jQuery, like described on JQuery's web:
http://docs.jquery.com/Using_jQuery_with_Other_Libraries
Priyanka Dhingra
RE: Related to jquery+ajax
November 6, 2012 5:28 AM
Answer

Priyanka Dhingra

Rank: Liferay Master

Posts: 501

Join Date: December 19, 2011

Recent Posts

are you able to see the following in your console???
1in serve resource method


i.e. is the serveResource() working???
Roberto Díaz
RE: Related to jquery+ajax
November 6, 2012 8:33 AM
Answer

Roberto Díaz

LIFERAY STAFF

Rank: New Member

Posts: 24

Join Date: October 30, 2012

Recent Posts

Specify your liferay version could help.

By the way, as Pavel told you,if you are using an old version try to use the Jquery notation instead of $.
Pranay R Patadiya
RE: Related to jquery+ajax
November 6, 2012 9:07 AM
Answer

Pranay R Patadiya

Rank: Regular Member

Posts: 179

Join Date: February 22, 2010

Recent Posts

Hi,
Can you please tell me, Which version of Liferay you are using?

Regards,
Pranay
deepthi narendula
RE: Related to jquery+ajax
November 7, 2012 12:06 AM
Answer

deepthi narendula

Rank: Junior Member

Posts: 39

Join Date: April 26, 2012

Recent Posts

Hi All,

I got the solution now it is working...

Thanks & Regards
N.Deepthi
Priyanka Dhingra
RE: Related to jquery+ajax
November 7, 2012 2:59 AM
Answer

Priyanka Dhingra

Rank: Liferay Master

Posts: 501

Join Date: December 19, 2011

Recent Posts

please share the solution, so that it may be useful for all of us
deepthi narendula
RE: solution Related to jquery+ajax
November 9, 2012 12:36 AM
Answer

deepthi narendula

Rank: Junior Member

Posts: 39

Join Date: April 26, 2012

Recent Posts

Hi priyanka,

I used dis code to delete data from database....

<script type="text/javascript">
function deleteSearch(ths){
var searchId=$(ths).attr('title');
var url = "<%=fetchValues%>";
$.ajax(url + "&searchId=" +searchId+ "&action=deleteSearch", function(data) {
});

}
</script>
This is my serve resource method :-
public void serveResource(ResourceRequest resourceRequest,
ResourceResponse resourceResponse) throws IOException,
PortletException {

System.out.println("in serve resource method");
String action = ParamUtil.getString(resourceRequest, "action");
if(action.equalsIgnoreCase("deleteSearch")){
int searchId=ParamUtil.getInteger(resourceRequest, "searchId");
try {
User_SearchLocalServiceUtil.deleteUser_Search(searchId);
} catch (PortalException e) {
e.printStackTrace();
} catch (SystemException e) {
e.printStackTrace();
}

}



Thanks & Regards
N.Deepthi