Hello All,I'm trying to do this :i have a form, and in this form there is a select where the user can choose an option…The form is default empty, cuz the user may create a new entry (in an input type text) OR choose existing entry in this list…and only 2 solutions in the select : - no selection (default selected) - charge existing choiceswhen the user selects "charge choices" the system calls a js function to get the data generated by another file(a .get.html.ftl file which consists in displaying some options created from freemarker code)on older versions of Alfresco (3.3) the request was done with a xmlhttprequest requesting the file hostort/alfresco/wcservice/folder/file/ on the system… it seems that on this version (4.2.0) this doesnt work anymore…the file generating the options looks like this :
<#assign liste=':'>
<#list "folder".children as X>
<#if X.name =="myName">
<#list X.children as Y>
<#list Y.children W>
<#if liste?index_of(':'+W.name+':')==-1>
<#assign liste=liste+W.name+':'>
</#if>
</#list>
</#list>
</#if>
</#list>
<#list liste?sort as xyz>
<#if xyz!=''>
<option value='${xyz?html}'>${xyz?html}</option>
</#if>
</#list>
calling this file on url (hostort/alfresco/wcservice/folder/thisFile/ returns the options!so the code is ok… but my problem is to get it by calling a jsfunction INTO another file…in this other file i have a select which looks like this :
…
<span id="span_sel_type">
<select id="sel_type" onChange="javascript:getOptions('type');">
<option value="0">no choice</option>
<option value="charge">Charge</option>
</select>
</span>
…
'type' is the name of the file returning the options, so that i can call the same function on other selects to request other files (if i need another list generated by a file called "otherTypes" or "subTypes" i just have to set "otherTypes" or "subTypes" in my jsFunction…)The js code looks like this, two functions, one building the select + options and returning it and the other one returns the options to the first one… :<javascript>function getOptions(x){ //the select with the "no choice option" var txt="<select id='sel_type'><option value='0'>no choice</option>"; //trying to get the options from the file… calling javascript "call function" var result = call('hostort/alfresco/wcservice/folder/'+x); //writing the options into the created select, then put it into my form (replaces the default empty select) document.getElementById('span_sel_'+x).innerHTML=txt+res+'</select>';}function call(x){ var xhr = null; var res = ""; if(window.XMLHttpRequest){ xhr = new XMLHttpRequest(); }else if(window.ActiveXObject){ try{ xhr = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ result = "Error"; } }else{ result = "XMLHTTPRequests not supported…"; } xhr.open("GET",x,false); xhr.send(''); //or null if(xhr.readyState == 4){ if(xhr.status == 200){ result = xhr.responseText; }else{ result = "Probelm : status = "+xhr.status+" on "+x; } } return result;}</javascript>So… i'm on that for hours and hours without finding any solution…I get an error (firebug tells me) at xhr.open("GET",x,false)…Seems like xmlhttprequests are not native supported on alfresco 4.2… or seems like my code is wrong…but can't find any solution… what's wrong…and btw, sorry if my question looks "so easy to resolve" for you…thanks a lot for any help…