![](/img/trans.png)
[英]Unable to call portlet resource url from javascript in liferay6.2
[英]Liferay: Call JSON service from portlet
我正在嘗試使用我的portlet javascript代碼調用json Web服務:在js/main.js
我有:
Liferay.Service(
'/Basic-portlet.hello/remote-hello',
{
name: ''
},
function(obj) {
console.log(obj);
}
);
當我將portlet添加到頁面時,只要頁面重新加載引發的javascript錯誤,此調用只執行一次:
Uncaught TypeError: undefined is not a function
A.mix.parseIOConfig
A.mix.parseInvokeArgs
Service main.js?browserId=other&lan....
(anonymous function)
當您嘗試從無需訪問AlloyUI的上下文調用Liferay JSON Web服務時,我已經看到了這種情況。
添加以下AUI導入:
<script src="http://cdn.alloyui.com/2.0.0/aui/aui-min.js"></script>
然后包裝您的服務調用,如下所示:
AUI().use('aui-base', function(A){
// Liferay Service invocation here
});
例如,
AUI().use('aui-base', function(A){
Liferay.Service(
'/user/get-user-by-email-address',
{
companyId: Liferay.ThemeDisplay.getCompanyId(),
emailAddress: 'test@liferay.com'
},
function(obj) {
console.log(obj);
}
);
});
我過去遇到過類似的問題。 嘗試禁用javascript minifier,看看是否能解決您的問題。 它解決了我的問題。
謝謝,高拉夫
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.