cancel
Showing results for 
Search instead for 
Did you mean: 

How to define alfresco webscript url to call from share

thbaymet
Champ in-the-making
Champ in-the-making
Hi,

I want to send json data from share client-side javascript to my alfresco webscript defined as com/mycompany/mywebscript.
My code looks like


Alfresco.util.Ajax.request({

  url: 'com/mycompany/mywebscript',
 
  dataObj: {
    mode: "test",
    submitType: "json"
  },
});


in share. I don't know how to define url value to my alfresco webscript.
Thanks.
4 REPLIES 4

aaditvmajmudar
Confirmed Champ
Confirmed Champ
You can call Alfresco webscript with below code with you url:

Alfresco.util.Ajax.request(
                    {
                       url: Alfresco.constants.PROXY_URI + {YOUR_ALF_WEBSCRIPT_URL},
                       method: Alfresco.util.Ajax.GET OR Alfresco.util.Ajax.POST,
                        dataObj:
                       {
                  
                       },
                       successCallback:
                       {
                          fn: this.success, // Success method call
                          scope: this
                       },
                       failureCallback:
                       {
                          fn: this.failure, // Failure method call
                          scope: this
                       }
                    });

Hope this helps you.

thbaymet
Champ in-the-making
Champ in-the-making
Thanks,

This is working. I'm able to send data to my alfresco webscript with this code.


Alfresco.util.Ajax.request({

            url: Alfresco.constants.PROXY_URI + "com/mycompany/annotation",

            method: Alfresco.util.Ajax.GET,
           
            dataObj: {
                mode: "test",
                submitType: "json"
            },

}),


Now how can I get this data in my webscript. In ftl file or in javascript(json) file ?
Thanks.

thbaymet
Champ in-the-making
Champ in-the-making
Ok. In my fileName.get.html.ftl I can get the json data sent from share client-side javascript file.

Ex:



Data received : ${args.mode}



Guess will be helpful for someone in the future.

rjohnson
Star Contributor
Star Contributor
On the assumption all is properly named you should have an object called json available to your recieving webscript and you get things from it using json.get("fieldname");