Fórum
Liferay.Service(...) causes JS error "a.Array.filter is not a function"
Harri Tuomela, modificado 8 Anos atrás.
Liferay.Service(...) causes JS error "a.Array.filter is not a function"
Junior Member Postagens: 44 Data de Entrada: 03/02/08 Postagens Recentes
Hi! I've implemented a custom jsonws and http://localhost:8080/api/jsonws/LiferayLayoutRelation-portlet.layoutrelation/get-public-layouts/company-id/10155/locale/fi_FI returns JSON array [["Test",2],["Welcome",1]]. However, when I try to access this service from portlet's view.jsp like this
How can I access custom jsonws from JavaScript?
Harri
<aui:script>
Liferay.Service(
'/LiferayLayoutRelation-portlet.layoutrelation/get-public-layouts',
{ "companyId": 10155, "locale": "fi_FI" },
function(obj) { console.log(obj); }
);
</aui:script>
I get a JavaScript error "Uncaught TypeError: a.Array.filter is not a function" which is caused by this statement in everything.jsp:var o=a.Array.filter(m,d.isFunction);
How can I access custom jsonws from JavaScript?
Harri
Jan Geißler, modificado 8 Anos atrás.
RE: Liferay.Service(...) causes JS error "a.Array.filter is not a function"
Liferay Master Postagens: 735 Data de Entrada: 05/07/11 Postagens Recentes
Hi!
Please add this snippet to your URL:
&js_fast_load=0&css_fast_load=0&strip=0
this will give you a better insight on what actually is failling. I have encountered this error, when there was a different error with my JavaScript. Not with the actual Service Call, but in some other part. Please take a look with Firebug (or any other tool) on the Java Script Console, if there are any traces where the error occured. (Disable js_fast_load though ;) )
Please add this snippet to your URL:
&js_fast_load=0&css_fast_load=0&strip=0
this will give you a better insight on what actually is failling. I have encountered this error, when there was a different error with my JavaScript. Not with the actual Service Call, but in some other part. Please take a look with Firebug (or any other tool) on the Java Script Console, if there are any traces where the error occured. (Disable js_fast_load though ;) )
Harri Tuomela, modificado 8 Anos atrás.
RE: Liferay.Service(...) causes JS error "a.Array.filter is not a function"
Junior Member Postagens: 44 Data de Entrada: 03/02/08 Postagens Recentes
Thanks Jan!
The problem is caused by liferay.js row 94:
I still have no idea how to cope with this issue.
The problem is caused by liferay.js row 94:
var callbacks = A.Array.filter(args, Lang.isFunction);
which is in the call stack originated by call to Liferay.Service(...).I still have no idea how to cope with this issue.
Jan Geißler, modificado 8 Anos atrás.
RE: Liferay.Service(...) causes JS error "a.Array.filter is not a function"
Liferay Master Postagens: 735 Data de Entrada: 05/07/11 Postagens Recentes
In the /api/jsonws view, you can get sample code of your Method. Did u try to execute that snippet generated?
Also try this one:
Also try this one:
<aui:script>
Liferay.Service(
'/LiferayLayoutRelation-portlet.layoutrelation/get-public-layouts',
{ companyId: 10155, locale: "fi_FI" },
function(obj) { console.log(obj); }
);
</aui:script>
Harri Tuomela, modificado 8 Anos atrás.
RE: Liferay.Service(...) causes JS error "a.Array.filter is not a function"
Junior Member Postagens: 44 Data de Entrada: 03/02/08 Postagens Recentes
I actually started with /api/jsonws generated JS:
It produces the error and so does your sample code.
Liferay.Service(
'/LiferayLayoutRelation-portlet.layoutrelation/get-public-layouts',
{
companyId: 10155,
locale: 'fi_FI'
},
function(obj) {
console.log(obj);
}
);
It produces the error and so does your sample code.
Harri Tuomela, modificado 8 Anos atrás.
RE: Liferay.Service(...) causes JS error "a.Array.filter is not a function" (Resposta)
Junior Member Postagens: 44 Data de Entrada: 03/02/08 Postagens Recentes
The method filter is provided by the YUI module "array-extras". Adding it to solved the problem.
<aui:script use="array-extras">
Liferay.Service(...);
</aui:script>