Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
k venkatesh
AUI().io.request(ajax call) is not working for Guest users in 6.0.6
May 4, 2012 7:17 AM
Answer

k venkatesh

Rank: Junior Member

Posts: 50

Join Date: February 20, 2012

Recent Posts

Hi I am working in Liferay 6.0.6 with MVC portlet.
I want to make ajax calls in my portlet.For this one I have written the following code in view.jsp:

 1<%
 2PortletURL actionURL = renderResponse.createActionURL();
 3actionURL.setParameter(ActionRequest.ACTION_NAME, "saveForm");
 4%>
 5<aui:script>
 6function submitForm(){
 7var A = AUI();
 8var url = '<%= actionURL.toString() %>';
 9A.io.request(
10url,
11{
12
13data: {
14param:'venky',
15},
16
17on: {
18failure: function() {
19},
20
21success: function(event, id, obj) {
22var instance = this;
23var message = instance.get('responseData');
24if (message) {
25alert(message);
26}
27else {
28alert('no data back from server');
29}
30}
31
32}
33}
34
35); //END of io Request
36
37}
38</aui:script>
39<aui:form action="<%= actionURL.toString() %>" method="post" name="fm" >
40<aui:input name="name" inlineField="true"/>
41<aui:input name="age" id="age" inlineField="true"/>
42<aui:button name="saveButton" onClick='submitForm();' value="Click Me" />


</aui:form>

It is working and getting response from "saveForm()" method of portlet class for sign users.But it is not working for guest users (non sign-in) users.
Please help me How to make ajax calls for guest users,it is very urgent for me.

Thanks in advance.
k venkatesh
RE: AUI().io.request(ajax call) is not working for Guest users in 6.0.6
May 7, 2012 4:26 AM
Answer

k venkatesh

Rank: Junior Member

Posts: 50

Join Date: February 20, 2012

Recent Posts

Hi all,

Did I miss anything for your reference ,please let me now,it is very urgent for me.Please suggest me.
Daniel Wilmes
RE: AUI().io.request(ajax call) is not working for Guest users in 6.0.6
May 7, 2012 4:56 AM
Answer

Daniel Wilmes

Rank: Regular Member

Posts: 164

Join Date: May 23, 2011

Recent Posts

<aiu:script>
function doAJAX(queryString){
var A = AUI();

var io = A.io.request(queryString, {
dataType : 'json',
on: {
success: function(id, obj) {
try{
alert(this.get('responseData').value);
},
failure: function() {
alert('Error deleting the notification.');
}
}
});


}

</aui:script>
<portlet:resourceURL var="jsonVar" id="jsonID" >
<portlet:param name="userID" value="<%=String.valueOf(user.getUserId())%>" />
</portlet:resourceURL>

<a href="javascript:;" onclick="doAJAX('<%=jsonVar%>');" title="someTitle" ></a>



@Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortletException, IOException {
JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
if (resourceRequest.getResourceID().equals("jsonID")) {
jsonObject.put("value", "HELLO");
}
PrintWriter writer = resourceResponse.getWriter();
writer.write(jsonObject.toString());
}


This is how I do ajax calls.
Loïc Dumont
RE: AUI().io.request(ajax call) is not working for Guest users in 6.0.6
March 4, 2013 2:50 AM
Answer

Loïc Dumont

Rank: Junior Member

Posts: 43

Join Date: April 27, 2010

Recent Posts

I know it's an old one, but it just arrived to me today and I found this thread without the answer, I hope this will help others.

The problem was that the aui-io-request module was not loaded.

1
2<aui:script use="aui-base">
3A.io.request...
4</aui:script>


Loading the module corrected the problem:

1
2<aui:script use="aui-base,aui-io-request">
3A.io.request...
4</aui:script>


I guest in connected mode, the module is loaded elsewhere...
Murali Krishna
RE: AUI().io.request(ajax call) is not working for Guest users in 6.0.6
February 15, 2014 4:12 AM
Answer

Murali Krishna

Rank: Junior Member

Posts: 35

Join Date: January 16, 2012

Recent Posts

HI,

add your portlet id along with portlet.add.default.resource.check.whitelist list property (see in portal.properties file). so it will bypass the security token.

Murali