Here is the JSP page tag for an input text element:
<input name="searchTextSpan" id="searchTextSpan" type="text"/>
Below is the AJAX call that loads on document.ready:
AUI().use("liferay-portlet-url", function(A) {
var resourceURL = Liferay.PortletURL.createResourceURL();
resourceURL.setPortletId("app_war_portlet");
resourceURL.setResourceId(resourceId);
require(["dojo/request", "dijit/registry", "dojo/on", "dojo/domReady!"], function(request){
request.post(resourceURL.toString(), {
query: ajaxData,
handleAs: "json"
}).then(function(data){
if(resourceId == 'inputTextClick'){
AUI().use("liferay-portlet-url", function(A) {
var resourceURL = Liferay.PortletURL.createResourceURL();
resourceURL.setPortletId("app_war_portlet");
if(data.cachetmpArr!=null && data.cachetmpArr.length>0){
var cacheList = JSON.stringify(data.cachetmpArr);
cacheList = cacheList.replace(/"/g, "'");
console.log('cacheList12 '+cacheList);//['106182233','206182233','306182233'];
$('#searchTextSpan').autocomplete({
width: 300,
max: 10,
delay: 100,
minLength: 1,
autoFocus: true,
cacheLength: 1,
scroll: true,
highlight: false,
source:cacheList,
}).focus(function(){
$(this).autocomplete("search", "");
});
}
});
}
});
})
})
The source attribute in the code above is causing a 404 URL error when attempting to accept the cacheList. Any suggestions on how to fix this?