cancel
Showing results for 
Search instead for 
Did you mean: 

Cross-Site Get request

seif
Confirmed Champ
Confirmed Champ
Hi everybody,
I try to invoke a repository webscript from share in ajax call
<javascript>
Alfresco.util.Ajax.request({
           
            url: "http://127.0.0.1:8080/alfresco/s/sample/groups/getUserGroups",

            method: Alfresco.util.Ajax.GET,

            dataObj: {
                username: "seif",
                nodeRef: "workspace://SpacesStore/7589fe98-c111-4948-910e-68e5d2643590"
            },
             successCallback: {

                  fn: function(res) {
                     if (res.json !== undefined)
                     {
                        var results = res.json;
                        alert(results);
                     }
                  },

            }
});
</javascript>

but i have this error in browser console
XMLHttpRequest cannot load http://127.0.0.1:8080/alfresco/s/sample/groups/getUserGroups?username=seif&…deRef=workspace%3A%2F%2F.... Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:9080' is therefore not allowed access.
Help pleaze.
2 REPLIES 2

muralidharand
Star Contributor
Star Contributor
Hi,
Does the share and Repo lives in the same server or different server?
Why do you want to specify the complete URL like <ode> url: "http://127.0.0.1:8080/alfresco/s/sample/groups/getUserGroups"</code>?
You should be able to use
Alfresco.constants.PROXY_URI
to send the request to Repository.

Hi,

Thank you muralidharand. I use different server and i use the  Alfresco.constants.PROXY_URI but the problem is not resolved. My webscript works only in internet explorer browser but i should always relog before i use the ajax call.