Foros de discusión

problem with Making AJAX Request Using Alloy UI In JavaScript

thumbnail
Parth Ghiya, modificado hace 9 años.

problem with Making AJAX Request Using Alloy UI In JavaScript

Junior Member Mensajes: 35 Fecha de incorporación: 2/07/13 Mensajes recientes
Hi
i am a newbie and followed some tutorials for the same topic.
My Requirement: Making AJAX Call in Javascript using Alloy UI
Here is my current situation

In My JavaScript i have written this to make a AJAX Request
var selectedHospitalId = A.one("#" + portletNameSpace + "hospital").get('value');
var portletResourceId=portletNameSpace+"getHospitalistsNames";
var getHospitalistsNames = Liferay.PortletURL.createResourceURL();
getHospitalistsNames.setPortletId(portletNameSpace + "parth");
getHospitalistsNames.setResourceId("test1");
var myAjaxRequest = A.io.request(
getHospitalistsNames.toString(), {
dataType:'text',
method : 'POST',
data : {
hospitalId : selectedHospitalId
},
on : {
success : function() {

}
}
});

But the serveResource Method in my java controller class doesnt get called..!!

Any Leads on the same topic????
thumbnail
Pankaj Kathiriya, modificado hace 9 años.

RE: problem with Making AJAX Request Using Alloy UI In JavaScript

Liferay Master Mensajes: 722 Fecha de incorporación: 5/08/10 Mensajes recientes
Any JS error you are getting in browser's error console?
thumbnail
Parth Ghiya, modificado hace 9 años.

RE: problem with Making AJAX Request Using Alloy UI In JavaScript

Junior Member Mensajes: 35 Fecha de incorporación: 2/07/13 Mensajes recientes
Nope... emoticon

The request is successful with status :200 ok
but the call doesnt go to serveResource in java controller class...
thumbnail
Pankaj Kathiriya, modificado hace 9 años.

RE: problem with Making AJAX Request Using Alloy UI In JavaScript

Liferay Master Mensajes: 722 Fecha de incorporación: 5/08/10 Mensajes recientes
You have set portletId in resourceUrl. Do you have any such portlet? Itseems you have set wrong portletId in resourceUrl.
thumbnail
Parth Ghiya, modificado hace 9 años.

RE: problem with Making AJAX Request Using Alloy UI In JavaScript

Junior Member Mensajes: 35 Fecha de incorporación: 2/07/13 Mensajes recientes
what should i do then??

Created the ResourceURL in Javascript and then set it's ID...

If i create the ResourceURL in JSP and then pass it to JS, it works fine
thumbnail
Ketan Savaliya, modificado hace 9 años.

RE: problem with Making AJAX Request Using Alloy UI In JavaScript

Regular Member Mensajes: 117 Fecha de incorporación: 3/03/11 Mensajes recientes
It's better to do bellow way..
parth:
create the ResourceURL in JSP and then pass it to JS, it works fine


if you want to set portletId in js then do like..
var portletId = "<portlet:namespace />";
portletId = portletId.substring(1,portletId.length-1);

Then set it to your resource url...
getHospitalistsNames.setPortletId(portletId);


HTH!!

Regard's
Ketan Savaliya
thumbnail
Parth Ghiya, modificado hace 9 años.

RE: problem with Making AJAX Request Using Alloy UI In JavaScript

Junior Member Mensajes: 35 Fecha de incorporación: 2/07/13 Mensajes recientes
Hi ..

I am passing the portlet namespace from JSP to JS and i am sure i am passing the right portlet:Namespace !
problem is call doesnt go to the serveResource Method in java controller class