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
This will allow the use of
A
andLiferay
. you can remove<aui:script>