Use <portlet:resourceURL/>
as ajaxURL(in your case) in jsp.jspf, in you are referring.
Instead of @RequestMapping annotation use @ResourceMapping, this change would resolve your issue.
Domanda
i have a liferay app than runs ok im trying to send to the server an ajax post but it fails actually the server responds ok and i can see the response in firefox developer tools however on debugging i just get Exception "typeError"
he is my client and server code
function getChildClaims(father){
var value = father.value;
var url = $("#ajaxUrl").val();
$.post(url,{'fatherId' : value})
.success(function(){
alert("good");
})
.error(function(xhr,textStatus,errorThrown){
alert(xhr.responseText);
});
}
and my server code
@RequestMapping(params="action=getChildClaimsAjax")
public void getChildClaims(ResourceRequest request,ResourceResponse response) throws NumberFormatException, EcareException_Exception, IOException{
List<CustomerClaim> childClaims =ServiceFactory.getCustomerService().getClaimByFatherId(Integer.parseInt(request.getParameter("fatherId")));
Gson gson = new Gson();
String json = gson.toJson(childClaims);
PrintWriter out = response.getWriter();
out.write(json);
out.flush();
out.close();
}
Soluzione
Use <portlet:resourceURL/>
as ajaxURL(in your case) in jsp.jspf, in you are referring.
Instead of @RequestMapping annotation use @ResourceMapping, this change would resolve your issue.