简体   繁体   中英

Liferay JavaScript Function is not defined

I am new to liferay and I have been trying to do Ajax but my script does not load inside the browser. I also tested it by inserting a simple alert.

I've been getting the " function is not defined " error.

Below is my liferay aui script:

Liferay.provide(window,'refreshFunction',
    function(param){
        alert('param: ' + param);
        A.one('#divToBeRefreshed').plug(A.LoadingMask);
        var mask = A.one('#divToBeRefreshed').loadingmask;
        mask.show();
        var dTime = new Date();
        var dynamicURL = '<%=resourceURL %>&t=' + dTime.getTime().toString();

        A.io.request(dynamicURL, {
            method: 'GET',
            cache: false,
            data : {
                param: param
            },
            on: {
                success: function(event, id, obj) {
                    var response = this.get('responseData');
                    mask.hide();
                    $('#divToBeRefreshed').html(response);
                },
                fail: function(event, id, obj) {
                    mask.hide();
                }
            }
        });
    },
    ['aui-base']    
);  </aui:script>

Is there something wrong in my script? what might be the problem? HELP!

Your script should be wrapped in

;(function(A, Liferay) {
<<your script>>
}

This will allow the use of A and Liferay . you can remove <aui:script>

在弹出标签中添加onclick =“ window.parent.MyFunctionInPageParents()”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM