Foren
Issue with AJAX call in Liferay Spring portlet
Subhasis Roy, geändert vor 9 Jahren.
Issue with AJAX call in Liferay Spring portlet
Expert Beiträge: 275 Beitrittsdatum: 20.01.12 Neueste Beiträge
Hi,
Facing some issue with AJAX call. Please find my code snippet below.
JSP code:
Controller Code:
This is not working for me. Some how the ajax call is not working and no error is also coming up in console. Need some help on this.
Facing some issue with AJAX call. Please find my code snippet below.
JSP code:
function loadMyInfo(){
$.ajax({
url : '<portlet:resourceurl id="getMyDataList" />',
type: 'POST',
dataType:'text',
contentType: "application/x-www-form-urlencoded; charset=utf-8",
data : formData,
success: function(data, textStatus, jqXHR){
// showSuccessResponse(data);
},
error: function (jqXHR, textStatus, errorThrown){
// showErrorResponse();
}
});
}
Controller Code:
@ResourceMapping("getMyDataList")
public void getMyData(ResourceRequest request, Model model,ResourceResponse response, Locale locale, PortletSession session) throws Exception {
System.out.print("Calling this method for AJAX Call");
...logic for other operations....
}
This is not working for me. Some how the ajax call is not working and no error is also coming up in console. Need some help on this.
David H Nebinger, geändert vor 9 Jahren.
RE: Issue with AJAX call in Liferay Spring portlet
Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
If I had to guess I'd say your URL is either not correct, not mapped to go to the method like you think, or not mapped to the POST protocol (and therefore not mapped to go where you think).
Thomas Berg, geändert vor 9 Jahren.
RE: Issue with AJAX call in Liferay Spring portlet
Regular Member Beiträge: 131 Beitrittsdatum: 07.09.09 Neueste Beiträge
Have you tried setting
<requires-namespaced-parameters> to false in liferay-portlet.xml?
<requires-namespaced-parameters> to false in liferay-portlet.xml?
Subhasis Roy, geändert vor 9 Jahren.
RE: Issue with AJAX call in Liferay Spring portlet
Expert Beiträge: 275 Beitrittsdatum: 20.01.12 Neueste Beiträge
Hi,
Its my mistake, as I forgot to include the jquery.min.js file in my jsp.
That's why my jQuery function is not getting called. Added the following line in the JSP file and it worked.
Its my mistake, as I forgot to include the jquery.min.js file in my jsp.
That's why my jQuery function is not getting called. Added the following line in the JSP file and it worked.
<script src="<%=renderRequest.getContextPath()%>/js/jquery-1.11.1.min.js"></script>
David H Nebinger, geändert vor 9 Jahren.
RE: Issue with AJAX call in Liferay Spring portlet
Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Bad bad bad idea.
To include javascript in the portlet you either a) add it into the theme or b) add it via the liferay-portlet.xml.
But you never, ever use the script tag to pull it in.
To include javascript in the portlet you either a) add it into the theme or b) add it via the liferay-portlet.xml.
But you never, ever use the script tag to pull it in.